Opened 8 years ago
Closed 8 years ago
#38832 closed defect (bug) (fixed)
WP_Image_Editor can no longer edit PDF pages other than the first one
Reported by: | kirasong | Owned by: | kirasong |
---|---|---|---|
Milestone: | 4.7 | Priority: | normal |
Severity: | normal | Version: | 4.7 |
Component: | Media | Keywords: | has-patch 2nd-opinion |
Focuses: | Cc: |
Description
After [39187], WordPress force-loads only the first page of a PDF.
As an unintended consequence, if developers were using/extending WP_Image_Editor_Imagick
to output other pages, this will be broken in the current state, and would require them to override load()
to work around it.
We should do at least one of the following:
- Find a way to pass desired pages to the editor
- Create a workaround for those cases
- Educate developers on the change
Attachments (2)
Change History (12)
This ticket was mentioned in Slack in #core-media by mike. View the logs.
8 years ago
#4
@
8 years ago
- Keywords has-patch 2nd-opinion added; needs-patch removed
I'm not very happy with this approach, but 38832.diff allows developers to override the PDF loading behavior to re-enable multi-page loads or change the DPI.
This approach would not solve the backcompat issue, but would allow working around it.
Separately, ping'd @ipstenu to see if it's possible to search the plugin repo for extends WP_Image_Editor_Imagick
-- if anyone else has a downloaded version, a search would be appreciated to make it easier to dig for plugin authors that have extended the Imagick editor for PDF reasons.
#5
@
8 years ago
27 plugins extending:
https://wordpress.org/plugins/ajax-search-lite/
https://wordpress.org/plugins/circles-gallery/
https://wordpress.org/plugins/connections/
https://wordpress.org/plugins/document-gallery/
https://wordpress.org/plugins/easy-related-posts/
https://wordpress.org/plugins/eazyest-gallery/
https://wordpress.org/plugins/elementor/
https://wordpress.org/plugins/ewww-image-optimizer/
https://wordpress.org/plugins/ewww-image-optimizer-cloud/
https://wordpress.org/plugins/foogallery/
https://wordpress.org/plugins/gravity-framework/
https://wordpress.org/plugins/hammy/
https://wordpress.org/plugins/image-carousel/
https://wordpress.org/plugins/improved-image-editor/
https://wordpress.org/plugins/post-thumbnail-editor/
https://wordpress.org/plugins/related-posts-lite/
https://wordpress.org/plugins/ricg-responsive-images
https://wordpress.org/plugins/sb-core/
https://wordpress.org/plugins/sb-post-widget/
https://wordpress.org/plugins/slideshow-gallery/
https://wordpress.org/plugins/smart-watermark/
https://wordpress.org/plugins/sp-client-document-manager/
https://wordpress.org/plugins/sp-rental-manager/
https://wordpress.org/plugins/tilecrop/
https://wordpress.org/plugins/twotonefx/
https://wordpress.org/plugins/wp-appointments/
https://wordpress.org/plugins/wp-thumb/
#6
@
8 years ago
38832.2.diff Takes a bit of a different approach here, reverting some of the PDF specific code in WP_Image_Editor_Imagick::load()
in favor of an approach that would allow someone to set resolution and page ranges on the editor instance before running the load()
method. The changes to wp_generate_attachment_metadata()
for generating thumbnails for PDFs shows how this could be used.
This was a pretty quick proof of concept, so testing and feedback would be appreciated.
#7
@
8 years ago
Hmm. Took a look; thanks for putting it together! Interesting workaround -- hadn’t thought about running _choose separately.
Two (related) notes:
- If we can, I’d prefer to avoid adding additional public methods on only one type of
WP_Image_Editor
, since it could lead to more third party code that will only work with the Imagick editor (but would fail if another editor is selected). - I’m not a huge fan of
update_file
being public, since theWP_Image_Editor
model is supposed to surround a single input file, and this would not have the effect expected by developers if run from outside of aWP_Image_Editor
.
#8
@
8 years ago
Thanks Mike. Those echo my main concerns with this approach as well, but was looking for a way to do this that:
a) Didn't introduce a new filterable value into the logic chain, and
b) Left PDF implementation details out of the load()
method to ensure backcompat with anything extending the WP_Image_Editor_Imagick
class.
The only other way I could see us getting around this is to put an action hook or filter between the instantiation of the Imagick object on $this->image
and the $this->image->readImage()
call.
Chatted with @markoheijnen a bit about this. He suggested we put the small amount of PDF logic that was added into a method that can be overridden, which would allow both changing how pages are handled and DPI.
Would probably be helpful to know how common the current use case is, since the above would still potentially break plugins that are extending the editor for PDF reasons.
I’d like to avoid a filter if we can, although it is definitely the "quick" way to fix it.