wp_get_attachment_image

FILTER wp-includes\media.php (ligne 986) github
This filter is documented in wp-includes/post.php  				$icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' );  				$src_file = $icon_dir . '/' . wp_basename( $src );  				list( $width, $height ) = wp_getimagesize( $src_file );  				$ext = strtolower( substr( $src_file, -4 ) );  				if ( '.svg' === $ext ) { 					// SVG does not have true dimensions, so this assigns width and height directly. 					$width  = 48; 					$height = 64; 				} else { 					list( $width, $height ) = wp_getimagesize( $src_file );
traduction française
Ce filtre est documenté dans wp-includes/post.php $icon_dir = apply_filters( 'icon_dir', ABSPATH . WPINC . '/images/media' ) ; $src_file = $icon_dir . '/' . wp_basename( $src ) ; list( $width, $height ) = wp_getimagesize( $src_file ) ; $ext = strtolower( substr( $src_file, -4 ) ) ; if ( '.svg' === $ext ) { // SVG n'a pas de vraies dimensions, donc ceci assigne la largeur et la hauteur directement. 					$width = 48 ; $height = 64 ; } else { list( $width, $height ) = wp_getimagesize( $src_file ) ;

Paramètres

Entrée :
$attachment_id, $size = 'thumbnail', $icon = false, $attr = ''
Sortie :
@param array|false  $image         {
@param int          $attachment_id Image attachment ID.
@param string|int[] $size          Requested image size. Can be any registered image size name, or
@param bool         $icon          Whether the image should be treated as an icon.
@param int          $attachment_id Image attachment ID.
@param string|int[] $size          Optional. Image size. Accepts any registered image size name, or an array
@param bool         $icon          Optional. Whether the image should be treated as an icon. Default false.
@param string|array $attr {
@return string HTML img element or empty string on failure.

Utilisation

Filtrer le HTML d'une image

Filtre pour modifier le HTML d'une image.

media frontend
add_filter('wp_get_attachment_image', 'wrap_images_in_figure', 10, 4);
function wrap_images_in_figure($html, $attachment_id, $size, $icon) {
    if (!$icon && is_singular()) {
        $html = '
' . $html . '
'; } return $html; }

Actualités

Chargement des actualités...