I used others post but not working, My currently problem is that I cannot seem.
how can i upload and use SVG
file in magento 2.3
? please help.
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityI believe that you want to use SVG images in cms pages.
For the quick solution got to
[your magento dir]\vendor\magento\module-cms\etc\di.xml
There you can see <type name="Magento\Cms\Model\Wysiwyg\Images\Storage">
add svg to the list like this
<argument name="extensions" xsi:type="array">
<item name="allowed" xsi:type="array">
<item name="jpg" xsi:type="string">image/jpg</item>
<item name="jpeg" xsi:type="string">image/jpeg</item>
<item name="png" xsi:type="string">image/png</item>
<item name="gif" xsi:type="string">image/gif</item>
<item name="svg" xsi:type="string">image/svg</item>
</item>
<item name="image_allowed" xsi:type="array">
<item name="jpg" xsi:type="string">image/jpg</item>
<item name="jpeg" xsi:type="string">image/jpeg</item>
<item name="png" xsi:type="string">image/png</item>
<item name="gif" xsi:type="string">image/gif</item>
<item name="svg" xsi:type="string">image/svg</item>
</item>
<item name="media_allowed" xsi:type="array">
<item name="flv" xsi:type="string">video/x-flv</item>
<item name="swf" xsi:type="string">application/x-shockwave-flash</item>
<item name="avi" xsi:type="string">video/x-msvideo</item>
<item name="mov" xsi:type="string">video/x-sgi-movie</item>
<item name="rm" xsi:type="string">application/vnd.rn-realmedia</item>
<item name="wmv" xsi:type="string">video/x-ms-wmv</item>
</item>
Hope this helps.
Please note that editing core files are not recommended. Please write it in your custom module.
Don't forget to clear cache
Attention, We don't recognize or support this file extension type.
Mar 1, 2019 at 7:20
Working fine with M2.3:
app/code/SR/MagentoCommunity/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Cms\Model\Wysiwyg\Images\Storage">
<arguments>
<argument name="extensions" xsi:type="array">
<item name="allowed" xsi:type="array">
<item name="svg" xsi:type="string">text/plain</item>
</item>
<item name="image_allowed" xsi:type="array">
<item name="svg" xsi:type="string">text/plain</item>
</item>
<item name="media_allowed" xsi:type="array">
<item name="svg" xsi:type="string">text/plain</item>
</item>
</argument>
</arguments>
</type>
</config>
[Update]
If this not still not working for you, You can debug what mime type is pass for this.
vendor/magento/framework/File/Uploader.php
/**
* Used to check if uploaded file mime type is valid or not
*
* @param string[] $validTypes
* @access public
* @return bool
*/
public function checkMimeType($validTypes = [])
{
error_log($this->_getMimeType());
if (count($validTypes) > 0) {
if (!in_array($this->_getMimeType(), $validTypes)) {
return false;
}
}
return true;
}
This error_log($this->_getMimeType()); is actual mimetype. Add this type instead text/plain. Mime Type text/plain is for Magento default logo that is use by luma theme.
File validation failed.
, i added in vendor/magento/module-cms/etc/di.xml
Mar 1, 2019 at 9:36
For Magento 2.3, You have to add this to di.xml of your custom module
<type name="Magento\Cms\Model\Wysiwyg\Images\Storage">
<arguments>
<argument name="extensions" xsi:type="array">
<item name="allowed" xsi:type="array">
<item name="svg" xsi:type="string">image/svg+xml</item>
</item>
<item name="image_allowed" xsi:type="array">
<item name="svg" xsi:type="string">image/svg+xml</item>
</item>
<item name="media_allowed" xsi:type="array">
<item name="svg" xsi:type="string">image/svg+xml</item>
</item>
</argument>
</arguments>
</type>