is there any way to change the default output when inserting a video into tinyMCE with Wordpress' default media manager. Currently it inserts it as a link, would it be possible to input it into the editor as an iFrame with all attributes intact.

Thanks in advance!


Copy paste from my answer here but with iframe/video mime type added:
Alter image output in content

function WPSE_80145_Mime($html, $id) {

//fetching attachment by post $id
$attachment = get_post($id); 
$mime_type = $attachment->post_mime_type;

//get an valid array of video types, add any extra ones you need   
$image_exts = array( 'video/mpeg', 'video/mp4', 'video/quicktime' );

//checking the above mime-type
if (in_array($mime_type, $image_exts)) { 

    // the image link would be great
    $src = wp_get_attachment_url( $id );

    // enter you custom output here, 
    //you will want to change this to what you want in the iframe
    $html = '<iframe><a href="' . $src .  '"></a></iframe>';
    return $html; // return new iframe wrapped video via $html    
    return $html;

add_filter('media_send_to_editor', 'WPSE_80145_Mime', 20, 2);
| improve this answer | |
  • Thanks for your help, just ended up making my own plugin :/ – abrosis Mar 4 '13 at 13:15

For that you will have to switch to the HTML (I think it is called text in 3.5) tab in the editor and insert the HTMML code of the iframe there. This will not work in network installation or if your user role is not editor or admin.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.