[SPIP] PUBLISHED : |embarque_src

SPIP

Article validated

The article « |embarque_src (https://www.spip.net/en_article6750.html) »
was validated by George.


|embarque_src

Saturday 17 September 2022 , by jack

The |embarque_src filter applied to an img tag passes its source as a
Data URI Scheme (https://en.wikipedia.org/wiki/Data_URI_Scheme) encoded in
base 64

Table of contents

  • Example
  • See also

The |embarque_src filter applied to a <img src="..." /> tag allows
you to modify the src attribute to generate and retrieve the image as a
base 64 encoded « Data URI Scheme » of the form: <img src="data:[<mediatype>][;base64],<data>" />.

Example|Back to the table of contents

[


(


#CHEMIN


{images/tdm.png}


|balise_img


)


]

returns
<img src="squelettes/images/tdm.png" width='16' height='16' />
while

[


(


#CHEMIN


{images/tdm.png}


|balise_img


|embarque_src


)


]

will return
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAFo9M/3AAAABGdBTUEAANb..." width='16' height='16'>

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

**Size Limit
The purpose of this filter is to embed small images.
If the image passed in is too large (default 4kb), the filter will not be
applied and will return the image path.

However, it is possible to force this setting

  1. [ ( #CHEMIN {img/newsletter_banner.png} |balise_img |embarque_src
    {9000} ) ]

NB: this filter is provided by the plugin-dist compressor, through the PHP
function filtre_embarque_src.
Caution : the result provided by this filter is not supported by all
browsers or e-mail clients.

See also|Back to the table of contents

Tags

Filters

P.S.
See also |embarque_fichier
(https://www.spip.net/ecrire/?exec=article&id_article=6749)

— Sent by SPIP (https://www.spip.net/)

rubon199-7e493.jpg