craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.29k stars 638 forks source link

SVG image upload in general settings causing error #2181

Open E2design opened 6 years ago

E2design commented 6 years ago

Description

Uploading an .svg image (image attached) in general settings causing a exception error. This tend to happen with images exported by Adobe Illustrator version (AI CC 22.0.1). Some other .svg images are accepted though.

Question?: How can I remove the image from the DB as I'm not able tot enter the general settings anymore

Steps to reproduce

  1. Upload the image under dashboard settings general (Both image upload positions have the same behavior)

Stack Trace

craft\errors\ImageException: The file “Asset-1.svg” does not appear to be an image. in /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/image/Raster.php:169
Stack trace:
#0 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/services/Images.php(201): craft\image\Raster->loadImage('/storage/av0418...')
#1 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/helpers/Image.php(197): craft\services\Images->loadImage('/storage/av0418...')
#2 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/variables/Image.php(64): craft\helpers\Image::imageSize('/storage/av0418...')
#3 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/variables/Image.php(74): craft\web\twig\variables\Image->getSize()
#4 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Extension/Core.php(1595): craft\web\twig\variables\Image->getWidth()
#5 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/helpers/Template.php(76): twig_get_attribute(Object(craft\web\twig\Environment), Object(Twig_Source), Object(craft\web\twig\variables\Image), 'width', Array, 'any', false, false)
#6 /storage/av04180/www/thetag_html/storage/runtime/compiled_templates/52/523864f0ea1fd8cbe00804cf0ab31bb52eb93621e60ebef0e2d5e185d72b2298.php(41): craft\helpers\Template::attribute(Object(craft\web\twig\Environment), Object(Twig_Source), Object(craft\web\twig\variables\Image), 'width', Array)
#7 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(389): __TwigTemplate_0822e530cf60d68726a638b2d54a4d2c3618d835e9989e0a8b7dee53f8c5b794->doDisplay(Array, Array)
#8 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(51): Twig_Template->displayWithErrorHandling(Array, Array)
#9 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(366): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#10 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(32): Twig_Template->display(Array, Array)
#11 /storage/av04180/www/thetag_html/storage/runtime/compiled_templates/77/7715882915831dc441b264d86c99f5d16248f47cf4c84bff2915d1440140f07d.php(29): craft\web\twig\Template->display(Array, Array)
#12 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(389): __TwigTemplate_be8c5ccb2e3e9ab458ce4cb3f2da41fbf1ee293ef96e07626603ff70d34449c4->doDisplay(Array, Array)
#13 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(51): Twig_Template->displayWithErrorHandling(Array, Array)
#14 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(366): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#15 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(32): Twig_Template->display(Array, Array)
#16 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(374): craft\web\twig\Template->display(Array)
#17 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Extension/Core.php(1304): Twig_Template->render(Array)
#18 /storage/av04180/www/thetag_html/storage/runtime/compiled_templates/12/12626b95f2e8491472f47f9819842b4faae3a060b1f9b4be920f2aa32989cb64.php(93): twig_include(Object(craft\web\twig\Environment), Array, 'settings/genera...')
#19 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(188): __TwigTemplate_b136d628a3c750a22eff7dda65003726f760b1b73ad9d1eb3fb7609e2cc0c05c->block_content(Array, Array)
#20 /storage/av04180/www/thetag_html/storage/runtime/compiled_templates/73/73134d11f67e8d0d2da083a34c92e74d889d8aa3f61a0360aedb91663b0a9b07.php(735): Twig_Template->displayBlock('content', Array, Array)
#21 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(188): __TwigTemplate_e954359236908fb2903049e0b3af3285d602715fce630d36c590f0f09530adec->block_main(Array, Array)
#22 /storage/av04180/www/thetag_html/storage/runtime/compiled_templates/73/73134d11f67e8d0d2da083a34c92e74d889d8aa3f61a0360aedb91663b0a9b07.php(627): Twig_Template->displayBlock('main', Array, Array)
#23 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(188): __TwigTemplate_e954359236908fb2903049e0b3af3285d602715fce630d36c590f0f09530adec->block_body(Array, Array)
#24 /storage/av04180/www/thetag_html/storage/runtime/compiled_templates/33/335a8d54e1de8b8a851f17eb891280c15e6a72398d84be47a892890baf8aa839.php(53): Twig_Template->displayBlock('body', Array, Array)
#25 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(389): __TwigTemplate_9e386509e6eb59386b8b18514a45d0df7089cf0fa9fd3769729ffd0cde937301->doDisplay(Array, Array)
#26 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(51): Twig_Template->displayWithErrorHandling(Array, Array)
#27 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(366): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#28 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(32): Twig_Template->display(Array, Array)
#29 /storage/av04180/www/thetag_html/storage/runtime/compiled_templates/fe/feb527bbe5b4bbd28c789276110e15560c22b7cb1c07ac2db0fc61613c047e12.php(36): craft\web\twig\Template->display(Array, Array)
#30 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(389): __TwigTemplate_b808e2aeeb3c362d5a10098da526ec0fd942cb21efa244973005266840e46510->doDisplay(Array, Array)
#31 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(51): Twig_Template->displayWithErrorHandling(Array, Array)
#32 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(366): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#33 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(32): Twig_Template->display(Array, Array)
#34 /storage/av04180/www/thetag_html/storage/runtime/compiled_templates/73/73134d11f67e8d0d2da083a34c92e74d889d8aa3f61a0360aedb91663b0a9b07.php(82): craft\web\twig\Template->display(Array, Array)
#35 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(389): __TwigTemplate_e954359236908fb2903049e0b3af3285d602715fce630d36c590f0f09530adec->doDisplay(Array, Array)
#36 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(51): Twig_Template->displayWithErrorHandling(Array, Array)
#37 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(366): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#38 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(32): Twig_Template->display(Array, Array)
#39 /storage/av04180/www/thetag_html/storage/runtime/compiled_templates/12/12626b95f2e8491472f47f9819842b4faae3a060b1f9b4be920f2aa32989cb64.php(35): craft\web\twig\Template->display(Array, Array)
#40 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(389): __TwigTemplate_b136d628a3c750a22eff7dda65003726f760b1b73ad9d1eb3fb7609e2cc0c05c->doDisplay(Array, Array)
#41 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(51): Twig_Template->displayWithErrorHandling(Array, Array)
#42 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(366): craft\web\twig\Template->displayWithErrorHandling(Array, Array)
#43 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/twig/Template.php(32): Twig_Template->display(Array, Array)
#44 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Template.php(374): craft\web\twig\Template->display(Array)
#45 /storage/av04180/www/thetag_html/vendor/twig/twig/lib/Twig/Environment.php(289): Twig_Template->render(Array)
#46 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/View.php(292): Twig_Environment->render('settings/genera...', Array)
#47 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/View.php(340): craft\web\View->renderTemplate('settings/genera...', Array)
#48 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/Controller.php(121): craft\web\View->renderPageTemplate('settings/genera...', Array)
#49 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/controllers/SystemSettingsController.php(105): craft\web\Controller->renderTemplate('settings/genera...', Array)
#50 [internal function]: craft\controllers\SystemSettingsController->actionGeneralSettings(Object(craft\models\Info))
#51 /storage/av04180/www/thetag_html/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#52 /storage/av04180/www/thetag_html/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#53 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/Controller.php(80): yii\base\Controller->runAction('general-setting...', Array)
#54 /storage/av04180/www/thetag_html/vendor/yiisoft/yii2/base/Module.php(528): craft\web\Controller->runAction('general-setting...', Array)
#55 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/Application.php(242): yii\base\Module->runAction('system-settings...', Array)
#56 /storage/av04180/www/thetag_html/vendor/yiisoft/yii2/web/Application.php(103): craft\web\Application->runAction('system-settings...', Array)
#57 /storage/av04180/www/thetag_html/vendor/craftcms/cms/src/web/Application.php(207): yii\web\Application->handleRequest(Object(craft\web\Request))
#58 /storage/av04180/www/thetag_html/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#59 /storage/av04180/www/thetag_html/web/index.php(21): yii\base\Application->run()
#60 {main}

Image

Asset 1.svg.zip

Additional info

RosanaRufer commented 6 years ago

Having this issue too after updating from beta-29 to RC1

I could upload them after opening and saving the files with Sketch

brandonkelly commented 6 years ago

Thanks, fixed for the next release.

johandouma commented 6 years ago

I'm getting the same error message when uploading SVG files to a local assets folder. Files were exported out of Illustrator CC and then processed with SVGO.

Exporting using Sketch resolves the issue though.

Tested in the lasted version 5dad916e8bc4824a08d2889bfb58e381704858b9

angrybrad commented 6 years ago

@johandouma can you share the SVG file?

wihodges commented 6 years ago

This still appears to be an issue with Craft 3.0.4 release. I was able to resave/export SVG via Sketch and then it will upload.

brandonkelly commented 6 years ago

@wihodges can you share the SVG file that was causing issues (pre-Sketch-export)? If not here, can you send it to support@craftcms.com?

wihodges commented 6 years ago

@brandonkelly just did a full test, created a new simple svg icon in illustrator, and tried to upload. Same error. I also ran this SVG in SVGO-GUI, which strips most everything out, still does not upload. I then opened the same SVG in Sketch and exported, and that version works. Quite strange b/c the minimized one from SVGO is about as code reduced as can be. The sketch svg output adds an XML tag to the top. Interestingly if you slap the XML type to the top of the file, it successfully uploads to craft.

<?xml version="1.0" encoding="UTF-8"?>

Three examples attached as zip: SVG FOR CRAFT UPLOAD TEST.zip