|
SPIP |
Article proposé
L’article « |balise_img_svg » est proposé à la publication depuis le samedi 28 février 2026.
|balise_img_svg
samedi 28 février 2026, par jack
The balise_img_svg filter allows to insert a <svg> tag or an <img> tag depending on whether its argument is an SVG file or another image format.
Indeed :
- the
balise_imgfilter inserts an<img>tag regardless of the type of image received as an argument, including when it is an SVG file - the
balise_svgfilter always inserts an<svg>tag.
The balise_img_svg filter is therefore useful when applied to an image whose format is unknown in advance and when you want SVG images to be inserted with an <svg> tag.
This filter is applied to the relative URL of an image file or an already formed image tag. It accepts the following optional parameters :
alt: alternative text (or a null value to explicitly not have an alt tag on the image instead of an empty alt)class: null by defaultsize: allows you to specify the size of the rendering (see syntax details : |balise_img)
Usage examples :
[(#LOGO_ARTICLE|balise_img_svg{'here application on an img tag', 'spip_logo'})]
[(#FICHIER|balise_img_svg{'here application on a file', 'spip_doc'})]
[(#CHEMIN{#GET{animage}}|balise_img_svg)]
— Envoyé par SPIP