Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
File entity version: 7.x-2.0-beta1+16-dev (also 7.x-2.x-dev)
I am experiencing an issue when replacing a file. Here are my steps to reproduce:
- Configure an image field for a content type and specify the allowed filetypes (i.e. jpg)
- Create a new piece of content and upload an image asset and save the node.
- Edit that piece of content and edit the image field.
- Replace the file using an illegal filetype (i.e. tif). The allowed file types are showing all extensions for the image type and not honoring my field values
- Save the file.
This seems like a bug. I would expect that my allowed types would be restricted to the values that I have configured for that field instance. I am setting a parent issue, because the bug may have been introduced in that issue. See: https://www.drupal.org/node/2271229
Comment | File | Size | Author |
---|---|---|---|
#9 | Screen Shot 2018-11-30 at 7.41.27 PM.png | 893.46 KB | Kristen Pol |
#9 | Screen Shot 2018-11-30 at 7.41.10 PM.png | 222.22 KB | Kristen Pol |
#9 | Screen Shot 2018-11-30 at 7.36.25 PM.png | 37.5 KB | Kristen Pol |
#9 | Screen Shot 2018-11-30 at 7.36.14 PM.png | 1009.85 KB | Kristen Pol |
#9 | Screen Shot 2018-11-30 at 7.34.07 PM.png | 1.16 MB | Kristen Pol |
Comments
Comment #1
agupta CreditAttribution: agupta commented^^ also the max file size isn't honored.
Comment #2
hussainwebI am updating the title for accuracy. I am also moving the other issue for parent to related list. Strictly speaking, that is not the reason why this bug came up. You wouldn't notice it earlier because the file extension was essentially locked to the already uploaded file.
This bug actually belongs to the media module (you are probably using that widget). There is no option to replace the file using the generic file widget. However, I am leaving this issue here as the fix would have to go in both the places. I think the way forward would be to match the behavior of upload file where the settings from field instance are shown correctly. When you click edit, these settings are not used and file_entity module uses the extension from the file type. It does not even check the upload size limit. I will work on a patch for the file_entity module in this issue and open a new issue in media module for it's patch.
Comment #3
hussainwebI have already uploaded the required patch for media module in #2562483-2: File validation settings are not used when editing a file. This is the patch required for file_entity to actually set the options on the file upload element. Both these patches are required for this to work. I have tested this against my setup and found that both extensions and file size settings are correctly shown when editing a file.
Comment #5
hussainwebFixing the failures (which were just notices).
Comment #6
joseph.olstadre-triggered tests, not sure if this patch still applies
Comment #8
joseph.olstadtestbot had a glitch, is fixed now, need to re-trigger the tests.
Comment #9
Kristen PolI reviewed the code and the changes seem pretty clear and I don't see any code standards issues.
I tested on simplytest.me and it appears to work as expected. I did the following based on the issue summary instructions:
Comment #10
Kristen PolComment #13
joseph.olstad