add_filter ( ‘media_send_to_editor’, …) does not work on wp 3.5

I have a problem with this -probably- abandoned plugin:

    <?php
/*
Plugin Name: RV Embed PDF
Description: When you upload PDF and insert a link to it with the Add Media button, it     will be automatically embedded in the page using Google Docs Viewer.
Author: Rong Vang Media
Author URI: http://www.rongvang.cz
Version: 1.0
*/
function rv_embedpdf($in){
$out = "";
if(preg_match("/href='(.*?\.pdf)'/", $in, $matches)){
    $out .= '<iframe src="http://docs.google.com/gview?url='.$matches[1].'&embedded=true" style="width:100%; height:500px;" frameborder="0"></iframe>';
}

$out .= $in;

return $out;
}
add_filter ( 'media_send_to_editor', 'rv_embedpdf' );

can anybody help me to make it compatible with wp 3.5?

Related posts

Leave a Reply

1 comment

  1. 'media_send_to_editor works fine in WordPress 3.5. I did not test the above code but you don’t need to preg_match for .pdf when WordPress supports post_mime_type == 'application/pdf;

    This should work better: https://gist.github.com/2176359
    Just change the HTML parameters to your needs. I also advise to embed it directly as an <iframe>, native .pdf iframe browser support is better than sending it through docs.google.com.