Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

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);
share|improve this answer
    
Thanks for your help, just ended up making my own plugin :/ –  abrosis Mar 4 '13 at 13:15
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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