WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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

Your Answer


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.