plemi/twig-extensions

dev-master 2013-07-06 12:10 UTC

This package is not auto-updated.

Last update: 2024-05-01 04:29:58 UTC


README

Base64 encoding for images

Basic Twig function to allow base64 images encoding following latest RFC.

Usage in the real world

First of all, add this to your composer.json.

{
    "require": {
        "plemi/twig-extensions": "dev-master"
    }
}

Symfony2

<service id="plemi.twig.base64_extension" class="Plemi\Twig\Extensions\Base64Extension" public="false">
    <tag name="twig.extension" />
</service>

Silex

<?php

// After registering Twig Silex Provider
$app['twig']->addExtension(new \Plemi\Twig\Extensions\Base64Extension());

Then in your twig templates, just call the function with the file path as an argument.

{{ image64('/images/logo.jpg') }}