Closed (fixed)
Project:
IMCE
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
8 Mar 2021 at 20:50 UTC
Updated:
11 Oct 2022 at 14:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
ufku commentedYou may consider using https://www.drupal.org/project/exif_orientation for all uploads across the site. However if you are limiting the max image dimensions on upload it may not work because the resizing takes place before exif_orientation fixes the image. https://www.drupal.org/project/exif_orientation/issues/2344175
Comment #3
jrbThis really is a problem with IMCE that can't be solved by using the EXIF Orientation module due to the way that IMCE sets the the file validators. EXIF Orientation works by either:
1. Adding a validator function before the
file_validate_image_resolution()validator with ahook_field_widget_form_alter()that will rotate the image.2. Using a
hook_file_presave()to do the rotation as the image is saved.These won't work with IMCE because (1) IMCE doesn't use form validators and (2) it's too late by the time presave is run because the EXIF data has already been stripped.
This could be fixed in IMCE in
ImcePlugin::opUpload()in a couple different ways:1. We could check if EXIF Orientation is enabled and add its validator function first.
2. More generally, we could add support for
hook_imce_file_upload_validators_alter()functions:Then, EXIF Orientation (or a custom module) would need to implement its own
exif_orientation_imce_file_upload_validators_alter()function to addexif_orientation_validate_image_rotation()to$validators.Either of these would allow EXIF Orientation (or other modules) to do its thing.
I've attached patches for each of these. If you wanted to do #2, we'd need to add an issue/patch to EXIF Orientation, too.
Comment #5
ufku commentedAdded
exif_orientation_validate_image_rotationas a validator beforefile_validate_image_resolution