Problem/Motivation
In #3218479: Site logo image is missing width and height we added logo width and height support for regular image. But often our logo is SVG image and that code will not work for SVG logo image case.
Let's try to cover this case. For sure SVG image is without dimension, it is a vector. But we can try to extract width and height dimensions from either width and height SVG attributes or viewBox attribute.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3389127-svg-logo-width-height-5.patch | 2.12 KB | pivica |
| #5 | interdiff-3389127-4-5.txt | 1.29 KB | pivica |
Comments
Comment #2
pivica commentedHere is a patch. Note that for this patch to work you first need a patch from #3344954: Logo accessibility problems, I guess it is a time for a new release ;)
This also needs a patch from #3389133: Add service for extraction dimensions from SVG image.
Comment #3
berdirthis assumes that the logo is svg, should we check the file extension?
I think it maks sense to do a getContainer()->hasService(), because if someone for some reason didn't update the module, it's going to be very hard to recover from this.
I assume we don't want to set only width or height, so we should make sure we either return both or nothing and then you can just do if ($dimensions).
Comment #4
pivica commented> 1. this assumes that the logo is svg, should we check the file extension?
This we are already doing here, right?
2. and 3. should be done, needed to do a new patch for related service in bs_lib https://www.drupal.org/project/bs_lib/issues/3389133#comment-15253540.
Comment #5
pivica commentedRemoved one extra if and added rounding to int.
Comment #7
pivica commentedCommitted.