• Resolved Guido

    (@guido07111975)


    Hi Andy and Alex,

    I’m using your plugin at a website that still has the Classic Editor installed, so just adding URL’s at the page. I notice the viewer has a maximum (fixed) width. In my case this means the PDF is still difficult te read. So is it possible to change that to full width?

    And when I change width of the embed-pdf-viewer object class, the width of the PDF stays the same.

    Guido

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

    (@afragen)

    There’s a filter you can use, but nothing directly on a per PDF basis.

    $atts = apply_filters( 'embed_pdf_viewer_pdf_attributes', $atts );

    The $atts is an array with $atts['height'] and $atts['width'] whose values are set as pixels.

    • This reply was modified 4 years, 6 months ago by Andy Fragen.
    Thread Starter Guido

    (@guido07111975)

    Hi Andy,

    Thanks, have added this simple code snippet in my theme functions file:

    
    // add custom height and width
    function my_callback() {
    	$atts['height'] = '1000';
    	$atts['width'] = '1200';
    	return $atts;
    }
    add_filter( 'embed_pdf_viewer_pdf_attributes', 'my_callback', 11 );
    

    Guido

    Plugin Author Andy Fragen

    (@afragen)

    You should pass the $atts parameter into the function also.

    function my_callback( $atts ) {

    Thread Starter Guido

    (@guido07111975)

    Thanks Andy,

    It does work without, but I’m not a hardcore coder so still have much to learn. Can you please explain why I need to add that?

    Guido

    Plugin Author Andy Fragen

    (@afragen)

    In WordPress, filter hooks always pass at least one parameter. This is the parameter or value that the user changes. If you know the format and expected contents of the return value then it’s not a problem.

    In this case, only returning the values for width and height and not the value for ‘title’, will result in a unset value for title.

    Perhaps a better way to explain this is when a filter passes an array, change the values you want and return the entire array.

    Thread Starter Guido

    (@guido07111975)

    Understood, thanks for the clarification!

    For other users with the same width issue: in my case the viewer had a certain width because of the Content Width that was set in file functions of my theme.

    Guido

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Viewer width’ is closed to new replies.