hook_file_presave triggers rotation twice

Created on 17 July 2024, 5 months ago

Problem/Motivation

The issue is mentioned in https://www.drupal.org/project/exif_orientation/issues/2895434 🐛 The module doesn't work with Imagick toolkit Active :

The module uses hook_file_presave (as opposed to hook_file_insert), so the image is processed every time it is [re]saved for whatever reason. In my configuration it was apparently saved two times.

Additionally to the issue above I'm also noticing that when I'm adding/removing the "Convert" effect to the "Thumbnail" image style it triggers the rotation while editing a media image. But even when the conversion is removed new images get rotated twice upon saving

Steps to reproduce

  • Add media -> Image (/media/add/image)
  • Upload an image with non empty exif:Orientation. In the preview the image appears rotated once which is correct
  • Save the media
  • The image appears rotated one more time at /admin/content/media

Proposed resolution

Instead of hook_ENTITY_TYPE_presave() use hook_file_insert() which gets triggered only once

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇨🇦Canada klimp Montréal, QC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024