MagestyApps / module-web-images

Magento 2 module for uploading images in optimised formats (SVG, WebP, etc.)
https://www.magestyapps.com
93 stars 16 forks source link

UI component image uploader does't work when allowedExtensions property is `false` #23

Closed tangar76 closed 5 months ago

tangar76 commented 5 months ago

Modules has mixin for UI component Magento_Ui/js/form/element/image-uploader. This mixin always extends allowedExtensions property with strings svg and webp. Originally in Magento when allowedExtensions has boolean value false then file with any extension can be uploaded. Property allowedExtenmsion has value false svg webp after running the mixin mentioned above. And almost any image file except svg and webp not possible to upload.

I offer next modification:

--- /tmp/fz3temp-2/image-uploader-mixin.js
+++ /tmp/fz3temp-2/image-uploader-mixin.js (Unsaved)
@@ -11,8 +11,10 @@
             initialize: function () {
                 this._super();

-                this.allowedExtensions += ' svg';
-                this.allowedExtensions += ' webp';
+                if (typeof this.allowedExtensions === 'string') {
+                    this.allowedExtensions += ' svg';
+                    this.allowedExtensions += ' webp';
+                }
             }
         });
     };
MagestyApps commented 5 months ago

@tangar76 this is a good one. Added the fix to version 1.1.8