Open adamlavery opened 3 months ago
Hi @adamlavery. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release@magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
There once was (back in 2017) a suggestion to be able to upload pdf files through a separate "file upload" mechanism that wouldn't abuse the "media gallery upload" (because pdf files aren't images that need to be resized to show a thumbnail): https://github.com/magento/magento2/issues/9850
Maybe that idea should get picked up again?
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
Area: XXXXX
label to the ticket, indicating the functional areas it may be related to.2.4-develop
branch@magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure. 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.Issue: Confirmed
once verification is complete. Hello @adamlavery,
Thanks for the report and collaboration!
We have tried to reproduce this issue in the latest development branch i.e. 2.4-develop and the issue seems reproducible for us. Currently, there is no way to upload files other than the ones mentioned in the existing module, need to override Magento_Backend/js/media-uploader.js to allow it.
Hence confirming the issue.
Thanks
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12718 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
@hostep this needs to be more flexible. It was already ridiculous how many duplicate DI entries needed to added. Poor design means each module needed to be told to allow additional types. There should be one single source of allowed CMS file types and it should be in admin, not require code changes. And it should be Media not Images; some sites need to use more than just images on CMS pages and want to use modern image formats nowadays (WEBP, AVIF) . For one of my customer stores we need the following. It's a print store and they provide templates in various formats for their customers to use.
<item name="allowed" xsi:type="array">
<item name="pdf" xsi:type="string">application/pdf</item>
<item name="eps" xsi:type="string">application/postscript</item>
<item name="idml" xsi:type="string">application/octet-stream</item>
<item name="ai" xsi:type="string">application/postscript</item>
<item name="psd" xsi:type="string">application/octet-stream</item>
<item name="zip" xsi:type="string">application/zip</item>
</item>
We already had to repeat this 3 times, now it's 5 times as each module has it's own separate config; as well as now also having to override the upload script!
Modern image converters can handle much more than just basic image files to generate thumbnails, including PDFs. If a format can't be converted, display a generic image type thumb.
Preconditions and environment
M2.4.7
Steps to reproduce
Implement DI overrides to allow more than just jpeg, jpg, png, gif files to be uploaded to the CMS media gallery e.g. add PDF
Expected result
PDF files can be uploaded and used in CMS content.
Actual result
PDF files are now disallowed again in 2.4.7
Additional information
Why are they now disallowed? Simple - some developer decided to "fix" a check for allowed files types in the media-uploader.js script. Instead of supplying allowed types to the script, as specified in DI, s/he hardcoded the allowed extensions in the script.
In fact someone thought of doing this in earlier versions but never followed it through - acceptFileTypes is never used:
Come on, how does this kind of schoolboy error make it into production? We learnt in the '80s that you never duplicate code/constants. If you do then your code is wrong and needs to be restructured to remove duplication.
Now, in addition to adding multiple DI entries to allow more file types in CMS content (which is also very poor code design), we have to override Magento_Backend/js/media-uploader.js to allow them, and manage core changes going forward.
Magento developers - you must do better! The time and cost of your errors is considerable.
Release note
Fix error introduced in 2,4.7 that negates DI changes to allow additional file types in CMS pages/blocks.
Triage and priority