From ed7ae10bc643304bb580fde36fc0fc769c313cdf Mon Sep 17 00:00:00 2001 From: Chi Date: Sun, 28 Jan 2024 11:31:03 +0000 Subject: [PATCH] Issue #3373333 by paulsheldrake, Chi: New filter to base64 encode and image --- docs/cheat-sheet.md | 9 +++++++++ src/TwigTweakExtension.php | 14 ++++++++++++++ tests/src/Functional/TwigTweakTest.php | 8 ++++++++ .../templates/twig-tweak-test.html.twig | 8 +++++++- twig_tweak.api.php | 2 ++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/docs/cheat-sheet.md b/docs/cheat-sheet.md index ce53075..642260c 100644 --- a/docs/cheat-sheet.md +++ b/docs/cheat-sheet.md @@ -285,6 +285,15 @@ This is an opposite of core `without` filter and adds properties instead of remo {{ content|with(['field_image', '#title'], 'Photo'|t) }} ``` +## Data URI +The filter generates a URL using the data scheme as defined in [RFC 2397](https://datatracker.ietf.org/doc/html/rfc2397) +```twig +{# Inline image. #} +'|data_uri('image/svg+xml') }}" alt="{{ 'Rectangle'|t }}"/> +{# Image from file system. #} +{{ 'Logo'|t }} +``` + ## Children ```twig