- Issue created by @paulsheldrake
- π¨π¦Canada paulsheldrake
Usage example
<img src="{{ drupal_svg_encode('/themes/custom/theme_name/assets/icons/icon-rss.svg') }}" {{ attributes|without('src') }}>
- πΊπ¦Ukraine vlad.dancer Kyiv
@paulsheldrake looks interesting. Any reason to limit it to svg only?
I would use it to show inline small image for pre-loading purpouses. - π¨π¦Canada paulsheldrake
Yeah, totally possible to example to other image types.
The reason I didn't here is:
- The project I'm on currently just needs it for SVGs :)
- Other file types can be quite large which then can cause memory issues, especially if there a lot of images to process.
That being said something to investigate more later if i get time
- π·πΊRussia Chi
https://twig.symfony.com/doc/3.x/filters/data_uri.html
There is a data URI filter in Twig but it lives in a separate Twig extension. Twig Tweak could just register that extensions in Drupal.
- π·πΊRussia Chi
Given that the filter is just a few lines of code we could just copy it into Twig Tweak.
- Status changed to Fixed
12 months ago 12:12pm 28 January 2024 - π·πΊRussia Chi
I've added
data_uri
filter. It will be available in the next release. Thank you. Automatically closed - issue fixed for 2 weeks with no activity.
- πͺπͺEstonia tormi Tallinn
@paulsheldrake looks interesting. Any reason to limit it to svg only?
I would use it to show inline small image for pre-loading purpouses.Please don't! We had an incident of backups of the production database failing due to large `data:image` chunks in the database.