You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When uploading file, height and width attributes not included in resulting tag. #4285
Description of the problem
When using a textarea, and uploading an image, the resulting <img> tag does not include the width and height attributes. If you instead select an image from the File picker, it does include those attributes.
How To Reproduce
Steps to reproduce the behavior:
Click file upload button on a Textarea field
Select a upload directory
Click 'Upload' button and find a file on your computer
view resulting <img> tag, missing height and width
Try the same process, but select existing image (even the one you just uploaded) and see width and height attribtutes in resulting tag
Environment Details:
Version: 7.4.9
PHP Version 8.2
MySQL Version 8
Possible Solution
Including 'file_hw_original' => $result['upload_response']['file_hw_original'], in the 'body' of the ajax response in Filepicker_mcp::ajaxUpload() seems to fix the issue for me.
I think I'm doing something different in trying to recreate the problem. I was trying to follow your steps exactly but here's a recording if you don't mind taking a look and telling me where I've gone wrong that would be greatly appreciated!
Hi @bryannielsen
Thanks for that screen recording! So, I'm not sure if it's because you don't have any images in your chosen upload directory, or if something is slightly different about our setups, but when I get to the part where I choose an "Upload Location" from the dropdown, I do not see the "Drop file(s) Here to Upload" drag target area thingymabob. I just see the list of files in that directory.
And I've been clicking the "Upload" button in the top right. When I click that, it opens the native file browser, and once I select a file, it closes that file browser dialog, i see the file upload progress, and then the file manager modal closes itself automatically, and that is when I get the image tag, sans height and width attributes.
Oh interesting, I did try with the upload button and in a directory that had files but the behavior was the same for me. I've never seen the modal close itself after the upload so I wonder if we have some JS behaving differently. I'm using Chrome on a mac, what browser are you using? (fingers crossed it's different!)
Hi again @bryannielsen . Thanks again for your time on this. I'm also using Chrome (Version 124.0.6367.203 (Official Build) (arm64)) on a Mac (Ventura 13.2 (22D49)).
I just confirmed that my system and theme ee directories have all the exact files from the EE 7.4.9 zip file.
I tested with the drag-and-drop files method, and that does upload the file and leaves the file list modal up, and clicking on the file then closes the modal and adds the img tag (with width and height attributes). But my fix/hack I mentioned already addressed that with the button method of uploading for me, so that's all good.
A separate issue that my client has identified is that, previously, on EE4, when uploading a file, you'd be presented with the file upload button, and also the input fields for "Description", "Credit", "Location", which they found useful to populate before adding the image to their entry. Now, in EE7, those fields do not show up when uploading an image, they have to go to their "Files" section, find the file, and edit it, to add those values.
Hi again @bryannielsen
I just installed a fresh version of EE 7.4.9 locally, and tested this out, and still seeing the same behavior. From a 100% fresh install, I added a channel, and a textarea field to it with "Show File chooser" enabled. Added a file upload directory (adapter: local, allowed file types: image, default browser view: list).
Then went to create an entry in that Channel, hit the file chooser button on my textarea. In the popup, chose my upload directory, then clicked the "Upload" button, chose a file, and it immediately closed the modal, and added the tag with no height or width attributes.
Here is the fix that I've applied locally to get this to include those attributes in the img tag in /ee/ExpressionEngine/Addons/filepicker/mcp.filepicker.php:
@GaryReckard thanks for taking the time to test on a fresh install and give me those detailed steps. I can reproduce this now and your fix looks good as well. Would you like to open a Pull Request with your change so that you can get credit for the work? We always want to encourage open source contributions and are extremely grateful for your time on this issue!
Activity
bryannielsen commentedon May 8, 2024
@GaryReckard thanks for opening this issue!
I think I'm doing something different in trying to recreate the problem. I was trying to follow your steps exactly but here's a recording if you don't mind taking a look and telling me where I've gone wrong that would be greatly appreciated!
GaryReckard commentedon May 8, 2024
Hi @bryannielsen
Thanks for that screen recording! So, I'm not sure if it's because you don't have any images in your chosen upload directory, or if something is slightly different about our setups, but when I get to the part where I choose an "Upload Location" from the dropdown, I do not see the "Drop file(s) Here to Upload" drag target area thingymabob. I just see the list of files in that directory.
And I've been clicking the "Upload" button in the top right. When I click that, it opens the native file browser, and once I select a file, it closes that file browser dialog, i see the file upload progress, and then the file manager modal closes itself automatically, and that is when I get the image tag, sans height and width attributes.
bryannielsen commentedon May 8, 2024
Oh interesting, I did try with the upload button and in a directory that had files but the behavior was the same for me. I've never seen the modal close itself after the upload so I wonder if we have some JS behaving differently. I'm using Chrome on a mac, what browser are you using? (fingers crossed it's different!)
GaryReckard commentedon May 17, 2024
Hi again @bryannielsen . Thanks again for your time on this. I'm also using Chrome (Version 124.0.6367.203 (Official Build) (arm64)) on a Mac (Ventura 13.2 (22D49)).
I just confirmed that my system and theme
eedirectories have all the exact files from the EE 7.4.9 zip file.I tested with the drag-and-drop files method, and that does upload the file and leaves the file list modal up, and clicking on the file then closes the modal and adds the img tag (with width and height attributes). But my fix/hack I mentioned already addressed that with the button method of uploading for me, so that's all good.
A separate issue that my client has identified is that, previously, on EE4, when uploading a file, you'd be presented with the file upload button, and also the input fields for "Description", "Credit", "Location", which they found useful to populate before adding the image to their entry. Now, in EE7, those fields do not show up when uploading an image, they have to go to their "Files" section, find the file, and edit it, to add those values.
GaryReckard commentedon May 17, 2024
Hi again @bryannielsen
I just installed a fresh version of EE 7.4.9 locally, and tested this out, and still seeing the same behavior. From a 100% fresh install, I added a channel, and a
textareafield to it with "Show File chooser" enabled. Added a file upload directory (adapter: local, allowed file types: image, default browser view: list).Then went to create an entry in that Channel, hit the file chooser button on my textarea. In the popup, chose my upload directory, then clicked the "Upload" button, chose a file, and it immediately closed the modal, and added the
tag with no height or width attributes.
Here is the fix that I've applied locally to get this to include those attributes in the img tag in

/ee/ExpressionEngine/Addons/filepicker/mcp.filepicker.php:bryannielsen commentedon May 18, 2024
@GaryReckard thanks for taking the time to test on a fresh install and give me those detailed steps. I can reproduce this now and your fix looks good as well. Would you like to open a Pull Request with your change so that you can get credit for the work? We always want to encourage open source contributions and are extremely grateful for your time on this issue!
Resolved ExpressionEngine#4285 by returning file_hw_original after aj…
Merge pull request #4327 from GaryReckard/bug/7.x/return-image-hw-on-…