Support » Plugin: Embed PDF Viewer » height attributes

  • Resolved imcobarn

    (@imcobarn)


    Hi,

    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?

    Thanks.

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

    (@afragen)

    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

    (@afragen)

    Plugin Author Andy Fragen

    (@afragen)

    This has been merged.

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

    imcobarn

    (@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 ago by .
    Plugin Author Andy Fragen

    (@afragen)

    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.