Uh oh!
There was an error while loading. Please reload this page.
add pdf thumbnail sizes to attachment data array - #504
Conversation
elliotcondon
commented
May 21, 2021
Hi @mjot Thanks for the PR. This looks logical and concise. Please allow me to add this into our dev to-do list to perform some testing. Thanks again! |
mjot
commented
May 21, 2021
Hello @elliotcondon, thanks for adding this to the dev to-do list. 👍 I think one thing you should pay special attention to is that with my changes all thumbnail sizes are added to the PDF as well. However, since Wordpress generates fewer thumbnails for PDF's and in addition only explicitly those that you register via the filter mentioned. So you could reduce that a little bit, if you want. I see no problem if it is not reduced, since each image size by default points to the original image. Just wanted to mention that. :) |
mjot
commented
Oct 14, 2022
I would like to know if this could be merged soon. :) |
With version 4.7 Wordpress got enhanced pdf support which automatically created thumbnails of the first page in different sizes when uploading a PDF.
It would be great if these thumbnails were automatically included in the attachment data array I get from a file field.
With my commit all sizes are added to the attachment data array.
But there is place for some optimization to only return thumbnail sizes possible for PDF's. By default these are:
$fallback_sizes = array( 'thumbnail', 'medium', 'large', );These can be extended by the filter
fallback_intermediate_image_sizes(doc) to add other image Sizes which were registered by theadd_image_size()function.I hope you find this pull request useful. Especially for download lists, which would be generated by repeater and file field, it would be handy to output the PDF thumbnail directly from the sizes array, without having to get the thumbnails via
wp_get_attachment_image_url().Thanks for your great plugin!
Martin