Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add pdf thumbnail sizes to attachment data array #504

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mjot
Copy link

@mjot mjot commented May 20, 2021

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 the add_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

@elliotcondon
Copy link
Contributor

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
Copy link
Author

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
Copy link
Author

mjot commented Oct 14, 2022

I would like to know if this could be merged soon. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants