src/Zicht/Bundle/FrameworkExtraBundle/Twig/Extension.php
public function embeddedImage($filename)
    {
        if (is_file($filename) && preg_match('/[.](?P<extension>[a-zA-Z0-9]+)$/', $filename, $matches)) {
            return sprintf('data:image/%s;base64,%s', $matches['extension'], base64_encode(file_get_contents($filename)));
        }

        return null;
    }
public function embeddedImage($filename)
    {
        if (is_file($filename) && preg_match('/[.](?P<extension>[a-zA-Z0-9]+)$/', $filename, $matches)) {
            return sprintf('data:image/%s;base64,%s', $matches['extension'], base64_encode(file_get_contents($filename)));
        }

        return null;
    }
public function embeddedImage ( $ filename ) { if ( is_file ( $ filename ) && preg_match ( '/[.](?P<extension>[a-zA-Z0-9]+)$/' , $ filename , $ matches ) ) { return sprintf ( 'data:image/%s;base64,%s' , $ matches [ 'extension' ] , base64_encode ( file_get_contents ( $ filename ) ) ) ; } return null ; }
Given an existing file, returns an embedded data stream, or null when the file does not exist

For example
{{ embedded_image('foo.jpg') }}
--> "data:image/jpg;base64,BLABLABLA"

@param string $filename
@return null|string
Given an existing file returns an embedded data stream or null when the file does not exist