experius / Magento-2-Module-Experius-WysiwygDownloads

Available At Packagist
https://packagist.org/search/?q=experius
Open Software License 3.0
98 stars 24 forks source link

SVG upload issues #32

Closed userwiths closed 4 months ago

userwiths commented 4 months ago

The issue

Uploading SVG generates an error. And after fixing the error, svg does not show in the list of files displayed.

The setup.

  1. composer require experius/module-wysiwygdownloads
  2. Have the module installed, enabled and active.
  3. Rebuild with magento setup:upgrade; magento setup:di:compile; magento setup:static-content:deploy -f;
  4. Clear cache and reindex
  5. Log into admin panel.
  6. Go to Content -> Pages -> Create/New Page
  7. Click on Insert Image icon.
  8. Select an SVG
  9. Receive error filename.svg: Disallowed file type.

Details

Does not upload file at all.

It seems that Magento2 uses a config option found under general/file/protected_permissions found in file ./vendor/magento/module-media-storage/Model/File/Validator/NotProtectedExtension.php (link leads to magento repo), it has a method isValid that is called by ./vendor/magento/module-media-storage/Model/File/Uploader.php's checkAllowedExtension.

File does not show in the file selection window.

Now after fixing the above issue (did a simple insert into the core_config_data table). I uploaded the SVG image, saw it is inside the folder through the console, but could not select it in magento because it was not showing with the other files. After a bit of searching I found this to be due to ./vendor/magento/module-media-gallery-integration/Plugin/SaveImageInformation.php's afterSave method which saves the record in the media_gallery_asset table. More specifically the isApplicable was evaluted to false because of the following condition. Here imageExtensions has the formats described in here in addition to the magento's default values.