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.

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?

share|improve this question

1 Answer 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.

share|improve this answer
    
[plugin author] Thanks, hotfix based on Wyck's help and linked plugin. Will update the plugin soon, thanks for suggestion. wordpress.org/support/topic/… –  premek.v Dec 26 '12 at 11:20

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.