Skip to main content
Bumped by Community user
Bumped by Community user
Better explanation of the problem.
Source Link
Casper
  • 409
  • 1
  • 6
  • 19

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' );

I try to create a shortcode for embedding a PDF file that is added to the post inside an Iframe. I came up with the following, but now my WordPress site isn’t working now.

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' );

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 thought, I should looking for a shortcode to embed the PDF file inside an iframe.

Problem

I am trying to create a WordPress shortcode that will get the src of the PDF file and paste it inside the src attribute, so the PDF will be visible inside the iframe. Only the below snippet of code will give me a white screen of WordPress, that isn’t working anymore.

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' );
Source Link
Casper
  • 409
  • 1
  • 6
  • 19

How to create a shortcode for embedding pdf in iframe?

I try to create a shortcode for embedding a PDF file that is added to the post inside an Iframe. I came up with the following, but now my WordPress site isn’t working now.

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' );