Problem/Motivation

If there is a form with an Image File type element, and the element is configured in Attachment Image Style to say re-size the image prior to sending an email - the uploaded file is sent, not the resized image.

In WebFormImageFile::getEmailAttachements - there is code to create the 'derivative' file - and that changes the variable $file_uri to point to the new file. However, as part of fixing https://www.drupal.org/project/webform/issues/3137981
the code a few lines down that sets the 'filepath' uses the original file name - not the new one.

Steps to reproduce

Proposed resolution

I believe the fix is easy - use $file_uri rather than $file->getFileUri():

'filepath' => $this->fileSystem->realpath($file->getFileUri()) ?: $file->getFileUri(),

becomes:
'filepath' => $this->fileSystem->realpath($file_uri) ?: $file_uri,

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jwag956 created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review
FileSize
875 bytes
jwag956’s picture

I am curious why you aren't using $file_uri in both parts of the if stmt - the new file (if there is one) is really what will be opened and sent. I am not sure the two would result in different results from 'realpath' but I suppose they could - if the image_style changed say the file type?

jrockowitz’s picture

I am open to suggestions. I think the code got tweaked by someone else's patch.

jwag956’s picture

Yes - looking at the history and other issue I referenced - someone made a fix, then someone else changed from $file->getFileUri() to $file_uri, then someone else realized the initial fix was incorrect and reverted it - wiping out the $file_uri change....

In any case - I am certainly no expert! but my suggestion as listed in the 'Proposed Resolution' was to change BOTH places that referenced $file->getFileUri() to reference $file_uri (which in the normal case of no image_style would be exactly the same effect.

jrockowitz’s picture

The last submitted patch, 6: 3229322-6.x-6.patch, failed testing. View results

jrockowitz’s picture

Status: Needs review » Reviewed & tested by the community

  • jrockowitz authored 666910d on 8.x-5.x
    Issue #3229322 by jrockowitz: Attachment Image Style doesn't send...

  • jrockowitz authored 666910d on 6.x
    Issue #3229322 by jrockowitz: Attachment Image Style doesn't send...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.