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
Comment | File | Size | Author |
---|---|---|---|
#6 | 3229322-8.x-5.x-6.patch | 893 bytes | jrockowitz |
| |||
#6 | 3229322-6.x-6.patch | 865 bytes | jrockowitz |
#2 | 3229322-2.patch | 875 bytes | jrockowitz |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at Webform module Open Collective, The Big Blue House commentedComment #3
jwag956 CreditAttribution: jwag956 as a volunteer commentedI 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?
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at Webform module Open Collective, The Big Blue House commentedI am open to suggestions. I think the code got tweaked by someone else's patch.
Comment #5
jwag956 CreditAttribution: jwag956 as a volunteer commentedYes - 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.
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at Webform module Open Collective, The Big Blue House commentedComment #8
jrockowitz CreditAttribution: jrockowitz as a volunteer and at Webform module Open Collective, The Big Blue House commentedComment #11
jrockowitz CreditAttribution: jrockowitz as a volunteer and at Webform module Open Collective, The Big Blue House commented