Support » Plugin: Embed PDF Viewer » height attributes

  • Resolved imcobarn



    Thank you for this great plugin.

    I see in the code if ( isset( $atts['height'] ) ) {

    Does that mean we can somehow set the height of the iframe?


Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Andy Fragen


    You can’t set it directly, but the media files attributes are merged and preferentially used.

    If this is something that many want to do I could put in a filter.

    Plugin Author Andy Fragen


    Plugin Author Andy Fragen


    This has been merged.

    You can use the embed_pdf_viewer_pdf_attributes filter hook to return an array of height and width.

    Thread Starter imcobarn


    Thank you very much, that works.

    I copied code from the Github and code below is what I’m using.

    I was trying to add “100%” width so it would scale on different screens but the function add “px” to the end of attribute so even if I add “500px” in new filter hook it would return 500pxpx on the page.
    So in the hook dimensions need to be without px.

    Anyway to get around that?

    add_filter( 'embed_pdf_viewer_pdf_attributes', function($attr) {
        $attr['height'] = "600";
        $attr['width'] = "1000";
        return $attr;
    • This reply was modified 2 years, 10 months ago by .
    Plugin Author Andy Fragen


    This may be difficult as the fallback is for the iframe, which specifically writes ‘px’ in the code. However, the object tag only has a number and it uses pixel for the unit of that number.

    Given that, I’m not sure there’s a way to accommodate. Sorry.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘height attributes’ is closed to new replies.