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.
This has been merged.
You can use the embed_pdf_viewer_pdf_attributes filter hook to return an array of height and width.
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 7 years, 10 months ago by
imcobarn.
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.