I love this mod and would find it useful if it could work with other formats as well as image for the file field. Would it be possible to make video & audio files work also?

I think users would find this very useful

Thanks for all your hardwork :)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hefox’s picture

This is actually rather simple patch, as far as I can tell, if one is assuming what someone wants to embed is an HTML 5 tag (else theirs some sort of outside depedency on x y z video player). e.g. for audio files, it could insert an audio tag, and video files could do video.

I believe there's some js scripts out there to change video tags to hosted video player in older browsers, may be the same for audio.

hefox’s picture

Status: Active » Needs review
FileSize
3.41 KB

Here's a patch that adds the audio tag

Note that filtered HTML doesn't allow audio tag by default :/

Note: it's missing other file formats, need to look up which ones are (commonly?) supported by audio tag.

quicksketch’s picture

Hm interesting. This seems like a good start, but I'm not sure if <audio> is widely supported enough yet to make it the only approach for an inline insertion. Same problem with <video>.

quicksketch’s picture

For example, it looks like Firefox (still) doesn't support MP3 audio tags: http://stackoverflow.com/questions/4923136/why-doesnt-firefox-support-mp...

hefox’s picture

Perhaps auto should have settings on what tags it applies per field? That way those that want it to automatically do audio for audio can, but others don't.

arrubiu’s picture

It could be useful also a simple "insert" button that adds a link to the file

quicksketch’s picture

Title: Working with other media formats » Working with other media formats (insert <video> and <audio> tags)
Status: Needs review » Needs work

It could be useful also a simple "insert" button that adds a link to the file

Insert module already provides an option to insert as a link to the file.

arrubiu’s picture

Yes, but, as I remember, it doesn't work if I have a file with "Media selector" widget.

drupal a11y’s picture

A solution for this is this module which also supports images: https://drupal.org/project/insert_video
The disadvantage is that it is a little buggy (insert button appears after saving node or pressing "add another item") and that the insert-presets are based on "view-modes".

grahl’s picture

Issue summary: View changes
FileSize
4.43 KB

I needed video support for this and adapted hefox's solution to do so. It only supports mp4 and no configuration, though that could of course be added.

mcruzvcn’s picture

FileSize
6.44 KB

Both patches are wrong implemented.
I have tried to apply them and they failed.

I removed both files and build a new patch using your code.

hacioglu’s picture

Hi,

I applied the patch in 11, but can still not upload files beside png, gif, jpg and jpeg. In the field settings I added mp4, but it didn't work.

What am I missing?

Snater’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Assigned: Unassigned » Snater
Status: Needs work » Needs review
FileSize
7.05 KB

I am browsing through old issues while working on the module's D8 version. There is also an issue regarding the D8 version: #2987311: Allow embedding audio/video
Audio and video tag seem to be pretty common by now. Yet, arguments that I mentioned in the D8 ticket, apply here as well.

Apart from that, It does not seem to be hard to implement and I attached a change set that should support embedding audio and video on generic file fields. This functionality could also be implemented in separate/custom module instead of directly in Insert by using hooks.

I will leave the change set here for a while and then decide on it. Please feel free to test and comment.

DrupalGideon’s picture

I had a cursory glance and noticed you're using short array syntax in this patch #13, which sadly shouldn't be used on D7.

https://www.drupal.org/docs/develop/standards/coding-standards#array

Snater’s picture

I guess I have been in D8 mode. ;) I will touch the code again before merging anyway, because it's probably not a good idea to figure out auto-detection by the mime type, as not all images and videos are rendered by all browsers. Maybe this should be a config option, as it would be a solution to #2918451: Add Support for inserting SVGs as images. as well.

Snater’s picture

The updated change adds a global configuration page to configure audio and video file type detection.

  • Snater committed 836eaaa on 7.x-1.x
    Issue #1431322: Support embedding audio and video files
    
Snater’s picture

Status: Needs review » Fixed

Apart from some slight improvements, the committed change does not set default file extensions that should be detected as audio/video files, as the change in behaviour of the "Automatic" Insert style would require tagging a new major version of the module.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.