|embarque_fichier

The filter |embarque_fichier allows you to replace a file embedded in a tag with its equivalent in Data URI Scheme encoded in base 64

  • New in : SPIP 2.1

The filter |embarque_fichier applied to a path to a file returns the base 64 encoded "Data URI Scheme" version of that file, which directly contains the data. Of the form: data:[<mediatype>][;base64],<data>.

Example

<img src="[(#CHEMIN{images/tdm.png})]">

will produce the tag
<img src="squelettes/images/tdm.png">

while

<img src="[(#CHEMIN{images/tdm.png}|embarque_fichier)]">

will produce the tag

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAFo9M/3AAAABGdBTUEAANb...>

...so the file will not be loaded from the source but displayed directly from the encoded string.

NB: this filter is provided by the plugin-dist compressor through the PHP function
filtre_embarque_fichier.

Caution : the result provided by this filter is not supported by all browsers or e-mail clients.

See also

Tags

Filters

Author jack Published : Updated : 02/07/23

Translations : English, français, Nederlands