SVG logo file upload

Is there any way to allow the upload of SVG logo file with out changing the core magento 2 file?

SVG Support

The svg files were removed from Magento as the format can allow javascript injections under certain scenarios (ref: Logo SVG format - logo not showing in most of browsers).

However, if security is not a concern then simply create a basic module and add the following file in the ‘etc/’ directory:

Filename: di.xml (Not tested)

<type name="Magento\Cms\Model\Wysiwyg\Images\Storage">
        <argument name="extensions" xsi:type="array">
            <item name="allowed" xsi:type="array">
                <item name="svg" xsi:type="string">image/svg+xml</item>
            <item name="image_allowed" xsi:type="array">
                <item name="svg" xsi:type="string">image/svg+xml</item>
            <item name="media_allowed" xsi:type="array">
                <item name="svg" xsi:type="string">image/svg+xml</item>


  1. As mentioned, it’s against security best practices to allow svg formats.
  2. I’ve not tested this code. I found it in this StackExchange article.

Building modules from scratch

The instruction manual for building the basic foundation of any module can be found in the Official Magento Documentation. There’s also a cool tool you can use called mage2gen - But you should still read the Magento Docs in order to understand how to use it.

Thank you much for your help I was able to get SVG upload done.Thank you very much for the info regard the security to the SVG file format.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.