New filter to base64 encode and image

Created on 7 July 2023, over 1 year ago
Updated 4 March 2024, 11 months ago

It would be nice to be able to pass a URL to an SVG and get a base64 encoded version to use in an image src attribute

file_URI|encode_base64_svg

would return something like this

data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTgiIGhlaWdodD0iMTgiIHZpZXdCb3g9IjAgMCAxOCAxOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTEwLjMwNTIgMTAuMzQ2QzEwLjAzNTEgMTAuMDYxIDkuNTYwNyA5Ljg3ODI4IDkuMDAwNjcgOS44NzgyOEM4LjQ0MDU3IDkuODc4MjggNy45NjYxNiAxMC4wNjEgNy42OTYwNSAxMC4zNDZDNy41NTUxMyAxMC40OTQ3IDcuNDgwNTkgMTAuNjQ3MSA3LjQ1NzEzIDEwLjg2NDNDNy40MTE2NCAxMS4yODQ4IDcuNDM3MTcgMTEuNjQ2OSA3LjQ4NjQ2IDEyLjIyNTlDNy41MzMzOSAxMi43Nzc1IDcuNjIyNTIgMTMuNTEzMiA3LjczODgzIDE0LjI2MjRDNy44MjE1OSAxNC43OTU2IDcuODg4ODMgMTUuMDgzNCA3Ljk1MDA3IDE1LjI4OTVDOC4wNDkzNSAxNS42MjM1IDguNDIwNCAxNS45MTU1IDkuMDAwNjcgMTUuOTE1NUM5LjU4MDg4IDE1LjkxNTUgOS45NTE5MiAxNS42MjM0IDEwLjA1MTIgMTUuMjg5NUMxMC4xMTI0IDE1LjA4MzQgMTAuMTc5NyAxNC43OTU2IDEwLjI2MjQgMTQuMjYyNEMxMC4zNzg4IDEzLjUxMzIgMTAuNDY3OSAxMi43Nzc1IDEwLjUxNDggMTIuMjI1OUMxMC41NjQxIDExLjY0NjkgMTAuNTg5NiAxMS4yODQ4IDEwLjU0NDEgMTAuODY0M0MxMC41MjA3IDEwLjY0NzIgMTAuNDQ2MSAxMC40OTQ3IDEwLjMwNTIgMTAuMzQ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4K

Some code out there as a starting point https://gist.github.com/bradyvercher/7952090

✨ Feature request
Status

Fixed

Version

3.2

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada paulsheldrake

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024