Problem/Motivation
The core module "Responsive Image" allows to use the "Responsive Image" formatter to display images with a <picture> HTML tag. If SVG Image is enabled on an image field which uses this formatter, the SVG images never gets rendered.
Proposed resolution
Override the responsive image formatter to display SVG images the same way they are handled by the image formatter.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | svg_image_responsive_support-2981263-2.patch | 9.16 KB | duaelfr |
Comments
Comment #2
duaelfrHere is a quick try.
Comment #3
dimr commentedIt works for me, thanks!
Comment #4
imyaro commentedHello,
Thanks for your contribution.
I have few little points to fix:
after the fixes I will gladly accept the patch
Comment #5
duaelfr@zvse Hi! Thanks for the review.
I've done the exact same things I found in
\Drupal\svg_image\Plugin\Field\FieldFormatter\SvgImageFormatter(). There is a width/height collection and no formatter settings summary. Should we fix both?Comment #6
norman.lolConfirming #2. Thank you! And thanks for this module. Keep up the good work!
Comment #7
markdcThanks for the patch. It works!
Comment #8
tijsdeboeckPatch #2 still works.
Would be nice to get this in a release.
Comment #9
hkirsman commentedIt works, tx!
Comment #10
rar9 commentedWhen will this be added to D8 so we dont need to patch?
Comment #11
duaelfrHi @zvse!
Would you please answer #5 so we know how to move this issue forward?
We might need to address your demands in a follow-up.
Thanks!
Comment #12
Daniel_N67536 commentedComment #14
imyaro commentedCommited to dev branch.
Thanks everyone
Comment #16
martijn de witJust a little note when you are updating to a newer version. (and wondering why things don't work anymore)
From up 8.x-1.12 you need to enable the SVG Image Responsive module that comes with this module :)
Comment #17
neurer commentedHint: Went from 1.10 to 1.13. After enabling the new svg_image_responsive.module logs gave me "Unable to generate the derived image located at (...)" for all responsive SVGs.
drush cache:rebuildfixed that for me.Comment #18
nikolabintev commentedHi everyone,
I see that the patch has been committed in 8.x-1.x, but it seems that there some aspects of the patch that are missing in the branch. For instance,
SvgResponsiveImageFormatter::classis not set onsvg_image_field_formatter_info_alterA sample of the patch:
and here is what is currently on 8.x-1.x branch: https://git.drupalcode.org/project/svg_image/-/blob/8.x-1.x/svg_image.mo...
Comment #19
martijn de wit@nikolabintev good catch. Because this issue is closed, it does not appears on everyones list anymore.
Best way to handle this thing is to open a new issue and link to this one.