Last active
September 20, 2017 23:32
-
-
Save wpscholar/1242548 to your computer and use it in GitHub Desktop.
WordPress shortcode loads a PDF file on your site in an iframe using Google Docs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* WordPress shortcode loads a PDF file on your site in an iframe using Google Docs. | |
* | |
* Example: [embed_pdf width="600px" height="500px"]http://infolab.stanford.edu/pub/papers/google.pdf[/embedpdf] | |
*/ | |
function embed_pdf($attr, $url) { | |
return '<iframe src="http://docs.google.com/viewer?url=' . $url . '&embedded=true" style="width:' .$attr['width']. '; height:' .$attr['height']. ';" frameborder="0">Your browser should support iFrame to view this PDF document</iframe>'; | |
} | |
add_shortcode('embed_pdf', 'embed_pdf'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment