[wp-trac] [WordPress Trac] #54531: Automatic image rotation using exif orientation incorrectly rotating images
WordPress Trac
noreply at wordpress.org
Mon Nov 29 08:16:49 UTC 2021
#54531: Automatic image rotation using exif orientation incorrectly rotating images
----------------------------+-----------------------------
Reporter: arthurdaly | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 5.8.2
Severity: normal | Keywords:
Focuses: administration |
----------------------------+-----------------------------
When uploading rotated images that contain EXIF orientation data wordpress
rotates them even though they're already rotated. I worked out that you
can prevent this using the following code but it doesn't affect the
thumbnail images, and they're still rotated.
{{{
add_filter('wp_image_maybe_exif_rotate', '__return_false');
}}}
I tried updating the metadata, but it didn't work to prevent the rotation
of the thumbnail images.
{{{
function prevent_thumbnail_rotation($metadata, $attachment_id) {
$metadata['image_meta']['orientation'] = '';
return $metadata;
}
add_filter('wp_update_attachment_metadata', 'prevent_thumbnail_rotation',
10, 2);
}}}
The images are all rotated correctly before upload.
After upload many have '-rotated' appending to the file name, if the above
code isn't used. This I want to avoid, as the images are to be attached
via csv import and each image filename will need to be manually edited if
it was rotated. The import fails if the image is rotated, even though the
actual file exists, it's probably not part of the attachment post.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54531>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list