A simple Twig extension to create base64-encoded strings from Craft [Image] Assets in your Twig templates.
This Twig extension requires that you pass an instance of a Craft Asset
in your Twig template. The extension will die gracefully if anything other than that is passed in as the first parameter.
{{ image64(asset) }}
{{ image64(asset, true) }}
This will return the base64-encoded string in a data URI scheme. The default value is false
.
{{ asset|image64 }}
{{ thumb64(asset) }}
{{ thumb64(asset, 200, true) }}
Second parameter is thumbnail width, default to 100px;
Setting third parameter to true
will return the base64-encoded string in a data URI scheme. The default value is false
.
{{ asset|thumb64 }}