tobimori / kirby-thumbhash

🚀 Smarter image placeholders with ThumbHash for Kirby
https://getkirby.com/plugins/tobimori/thumbhash
MIT License
28 stars 1 forks source link

SVG image issue #4

Open alkachur opened 7 months ago

alkachur commented 7 months ago

If for some reason one of the images will be in SVG format it will break the site with a 500 error. I think it should be some internal function of the plugin that will check formats, and if the format is SVG or some format that the plugin couldn't work with to not do thumb at all. It's better than ruining all site.

foxacid commented 5 months ago

👀 This just happened to us with AVIF

samlinck commented 5 months ago

I think I have the same issue:

Illuminate\View\ViewException thrown with message "imagecreatefromstring(): Data is not in a recognized format (View: /var/www/html/site/plugins/artomic/ui/02_atoms/visual/visual.blade.php) (View: /var/www/html/site/plugins/artomic/ui/02_atoms/visual/visual.blade.php) (View: /var/www/html/site/plugins/artomic/ui/02_atoms/visual/visual.blade.php) (View: /var/www/html/site/plugins/artomic/ui/02_atoms/visual/visual.blade.php)"

Stacktrace:
#53 Illuminate\View\ViewException in /var/www/html/site/plugins/kirby-thumbhash/classes/ThumbHash.php:50
#52 Illuminate\View\Engines\CompilerEngine:handleViewException in /var/www/html/vendor/illuminate/view/Engines/PhpEngine.php:60
#51 Illuminate\View\ViewException in /var/www/html/site/plugins/kirby-thumbhash/classes/ThumbHash.php:50
#50 Illuminate\View\Engines\CompilerEngine:handleViewException in /var/www/html/vendor/illuminate/view/Engines/PhpEngine.php:60
#49 Illuminate\View\ViewException in /var/www/html/site/plugins/kirby-thumbhash/classes/ThumbHash.php:50
#48 Illuminate\View\Engines\CompilerEngine:handleViewException in /var/www/html/vendor/illuminate/view/Engines/PhpEngine.php:60
#47 Illuminate\View\ViewException in /var/www/html/site/plugins/kirby-thumbhash/classes/ThumbHash.php:50
#46 Illuminate\View\Engines\CompilerEngine:handleViewException in /var/www/html/vendor/illuminate/view/Engines/PhpEngine.php:60
#45 Whoops\Exception\ErrorException in /var/www/html/site/plugins/kirby-thumbhash/classes/ThumbHash.php:50
#44 imagecreatefromstring in /var/www/html/site/plugins/kirby-thumbhash/classes/ThumbHash.php:50
#43 tobimori\ThumbHash:encode in /var/www/html/site/plugins/kirby-thumbhash/index.php:11
#42 Kirby\Cms\File:{closure} in [internal]:0
#41 Closure:call in /var/www/html/kirby/src/Cms/HasMethods.php:39
#40 Kirby\Cms\File:callMethod in /var/www/html/kirby/src/Cms/File.php:115
#39 Kirby\Cms\File:__call in /var/www/html/storage/cache/views/6de4dfe08bb1618102e8922797fc0d5a.php:44
#38 require in /var/www/html/vendor/illuminate/filesystem/Filesystem.php:123
#37 Illuminate\Filesystem\Filesystem:Illuminate\Filesystem\{closure} in /var/www/html/vendor/illuminate/filesystem/Filesystem.php:124
#36 Illuminate\Filesystem\Filesystem:getRequire in /var/www/html/vendor/illuminate/view/Engines/PhpEngine.php:58
#35 Illuminate\View\Engines\PhpEngine:evaluatePath in /var/www/html/vendor/illuminate/view/Engines/CompilerEngine.php:72
#34 Illuminate\View\Engines\CompilerEngine:get in /var/www/html/vendor/illuminate/view/View.php:207
#33 Illuminate\View\View:getContents in /var/www/html/vendor/illuminate/view/View.php:190
#32 Illuminate\View\View:renderContents in /var/www/html/vendor/illuminate/view/View.php:159
#31 Illuminate\View\View:render in /var/www/html/vendor/illuminate/view/Concerns/ManagesComponents.php:103
#30 Illuminate\View\Factory:renderComponent in /var/www/html/storage/cache/views/f9879868b25098368ee9c78677ec5620.php:46
#29 require in /var/www/html/vendor/illuminate/filesystem/Filesystem.php:123
#28 Illuminate\Filesystem\Filesystem:Illuminate\Filesystem\{closure} in /var/www/html/vendor/illuminate/filesystem/Filesystem.php:124
#27 Illuminate\Filesystem\Filesystem:getRequire in /var/www/html/vendor/illuminate/view/Engines/PhpEngine.php:58
#26 Illuminate\View\Engines\PhpEngine:evaluatePath in /var/www/html/vendor/illuminate/view/Engines/CompilerEngine.php:72
#25 Illuminate\View\Engines\CompilerEngine:get in /var/www/html/vendor/illuminate/view/View.php:207
#24 Illuminate\View\View:getContents in /var/www/html/vendor/illuminate/view/View.php:190
#23 Illuminate\View\View:renderContents in /var/www/html/vendor/illuminate/view/View.php:159
#22 Illuminate\View\View:render in /var/www/html/vendor/illuminate/view/Concerns/ManagesComponents.php:103
#21 Illuminate\View\Factory:renderComponent in /var/www/html/storage/cache/views/58dbacd45024730a45d1db4b61211054.php:28
#20 require in /var/www/html/vendor/illuminate/filesystem/Filesystem.php:123
#19 Illuminate\Filesystem\Filesystem:Illuminate\Filesystem\{closure} in /var/www/html/vendor/illuminate/filesystem/Filesystem.php:124
#18 Illuminate\Filesystem\Filesystem:getRequire in /var/www/html/vendor/illuminate/view/Engines/PhpEngine.php:58
#17 Illuminate\View\Engines\PhpEngine:evaluatePath in /var/www/html/vendor/illuminate/view/Engines/CompilerEngine.php:72
#16 Illuminate\View\Engines\CompilerEngine:get in /var/www/html/vendor/illuminate/view/View.php:207
#15 Illuminate\View\View:getContents in /var/www/html/vendor/illuminate/view/View.php:190
#14 Illuminate\View\View:renderContents in /var/www/html/vendor/illuminate/view/View.php:159
#13 Illuminate\View\View:render in /var/www/html/vendor/illuminate/view/Concerns/ManagesComponents.php:103
#12 Illuminate\View\Factory:renderComponent in /var/www/html/storage/cache/views/106c6d7316ab9785cb7733d86c2df50b.php:47
#11 require in /var/www/html/vendor/illuminate/filesystem/Filesystem.php:123
#10 Illuminate\Filesystem\Filesystem:Illuminate\Filesystem\{closure} in /var/www/html/vendor/illuminate/filesystem/Filesystem.php:124
#9 Illuminate\Filesystem\Filesystem:getRequire in /var/www/html/vendor/illuminate/view/Engines/PhpEngine.php:58
#8 Illuminate\View\Engines\PhpEngine:evaluatePath in /var/www/html/vendor/illuminate/view/Engines/CompilerEngine.php:72
#7 Illuminate\View\Engines\CompilerEngine:get in /var/www/html/vendor/illuminate/view/View.php:207
#6 Illuminate\View\View:getContents in /var/www/html/vendor/illuminate/view/View.php:190
#5 Illuminate\View\View:renderContents in /var/www/html/vendor/illuminate/view/View.php:159
#4 Illuminate\View\View:render in /var/www/html/site/plugins/artomic/src/Template.php:40
#3 Artcoresociety\Artomic\Template:render in /var/www/html/kirby/src/Cms/Page.php:1017
#2 Kirby\Cms\Page:render in /var/www/html/kirby/src/Cms/App.php:775
#1 Kirby\Cms\App:io in /var/www/html/kirby/src/Cms/App.php:1189
#0 Kirby\Cms\App:render in /var/www/html/public/index.php:23
tobimori commented 5 months ago

If it happens with AVIF, your PHP version is most likely not compiled/not supported to support AVIF.

samlinck commented 5 months ago

I just checked and if I only load the svg without avif or webp sources, it still happens. So I think it's something related with SVG and thumbhash.

tobimori commented 5 months ago

I know. But in this case, please add your own check.

samlinck commented 5 months ago

Okay, that was my current solution. Thanks.