#StackBounty: #8 #forms #media How can I auto-rotate an image on file upload in a custom form?

Bounty: 100

I’m using the FAPI to provide the user an upload field for an image. The field is:

$form['product_img'] = [
  '#type' => 'managed_file',
  '#description' => 'Upload a PNG or JPG image of the product.',
  '#multiple' => FALSE,
  '#required' => TRUE,
  '#upload_location' => 'public://',
  '#upload_validators' => [
    'file_validate_is_img' => [],
    'file_validate_extensions' => ['png jpg jpeg']

A lot of the users are uploading images taken with their mobile device, resulting in the image in landscape.

The solutions I’ve seen involve the default file upload widget, but I need something that will automatically rotate the image after the upload.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.