Closed (fixed)
Project:
Twig Tweak
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 May 2019 at 00:30 UTC
Updated:
24 Jul 2019 at 13:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
phjouComment #3
phjouSorry I put the first broken patch. The good now is there now.
Comment #4
phjouComment #5
chi commentedWith this patch
image_stylewill return the path for SVG image as is, which is inconsistent with core behavior.From the change record:
I think we should follow the same approach. Simply return NULL if image format is not supported.
Comment #6
phjou@Chi Ok I got your point. But should we change the API then? This module is supposed to make developers life easier, but basically you can't use that filter each time you allow an image format that is not supported. And since svgs are more and more used, I feel that filter is kind of useless.
For me, it is more confusing to have nothing displayed than the original image. And the behaviour you describe doesn't seem to happen, an error is thrown when the format is not supported. So I think that it is not handled properly, but maybe I'm wrong.
Comment #7
chi commentedIsn't that true for Drupal core as well? If you upload SVG it won't be displayed through image formatter unless it is supported by image toolkit.
Also it is not a big deal to apply the filter conditionally.
{% if uri|split('.')|last != 'svg' %} {{ uri|image_style('large') }} {% endif %}Comment #8
phjouYeah, you're right.
Maybe it's going to change in the future but for now it looks to be the case.
I'm a little bit confused because there is an issue that seems to have allowed svg but in fact it's not working when you try.
Allow image fields to use any extensions the current image toolkit supports (instead of hard-coding jpg, png and gif only)
So I am lost but you're right the core doesn't add support for svgs yet so we probably should leave it.
Comment #9
chi commentedThen we need just add
$image_style->supportsUri($path)condition to avoid errors.Comment #11
chi commentedI've added custom error for this case. Thanks.