General information
I am creating a site with WordPress. For the content I want that the PDF files can be embedded inside an iframe. So I first created a WordPress function to hook in `media_send_to_editor`, but the problem with this function is, that the iframe will reserve a lot of space inside the visual editor of WP, so other editing to that page isn’t good for the usability.So I try to create a shortcodethought, I should looking for embedding a PDF file that is addedshortcode to embed the postPDF file inside an Iframeiframe.
Problem
I came up witham trying to create a WordPress shortcode that will get the followingsrc of the PDF file and paste it inside the src attribute, but now myso the PDF will be visible inside the iframe. Only the below snippet of code will give me a white screen of WordPress site, that isn’t working nowanymore.
Look out for some advice. Thank you.
function embed_pdf_files( $atts, $content = null ) {
extract(shortcode_atts(array(
$src = wp_get_attachment_url();
), $atts));
return '<iframe width="100%" height="1000" src="' . $content . '"></iframe>';
}
add_shortcode( 'embed_pdf' , 'embed_pdf_files' );