craft-imageoptimize
craft-imageoptimize copied to clipboard
Craft 4 & automatically SVG transforms in the CP
Describe the bug
I noticed a bug that every time when entering any entry in the CP where the SVG image is used, CraftCMS tries to transform it and thus causes an error. StrackTrace errors in this case leads to the plugin (see logs). At the moment, I don't have any transforms for assets. FieldType for images -> just AssetField, not OptimizeField. The image is stored on S3, Sharp is selected as a transformer. Tested on 2 sites with the same version of Craft & plugin - in both cases, SVG images triggers an error
To reproduce
In any entry, add an asset field and upload an image in SVG format Refresh page Check the logs
Expected behaviour
There must be no transformation
Screenshots
Check logs
Versions
- Plugin version: 4.0.2
- Craft version: Craft 4.2.3
trace.log <- HERE
You should be able to disable the transformation of SVG images via the OptimizedImages field settings. Does that not work for you?
@khalwat Thanks for the reply Forgot to add, the error is caused by converting images in the CP panel like miniatures/thumbnails in the entry for the example: https://i.imgur.com/8vIV1dC.png. That's happens only for the SVG images.
Thumbnail transformation is intercepted by EVENT_TRANSFORM_IMAGE and I don't see a way to turn it off for the auto-transforms in the CP
That's a good idea for a feature flag: the ability to disable transforms for CP requests
@Romanavr shouldn't thumbnails be intercepted by Assets::EVENT_DEFINE_THUMB_URL -> https://github.com/nystudio107/craft-imageoptimize/blob/develop-v4/src/ImageOptimize.php#L314
@Romanavr shouldn't thumbnails be intercepted by
Assets::EVENT_DEFINE_THUMB_URL-> https://github.com/nystudio107/craft-imageoptimize/blob/develop-v4/src/ImageOptimize.php#L314
There is a problem with regular SVG images as well (not thumbnails)
According to the strack trace, I see that it looks exactly at this event, not the Assets::EVENT_DEFINE_THUMB_URL