wp_get_attachment_image хук-фильтрWP 5.6.0

Filters the HTML img element representing an image attachment.

Использование

add_filter( 'wp_get_attachment_image', 'wp_kama_get_attachment_image_filter', 10, 5 );

/**
 * Function for `wp_get_attachment_image` filter-hook.
 * 
 * @param string       $html          HTML img element or empty string on failure.
 * @param int          $attachment_id Image attachment ID.
 * @param string|int[] $size          Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
 * @param bool         $icon          Whether the image should be treated as an icon.
 * @param string[]     $attr          Array of attribute values for the image markup, keyed by attribute name. See wp_get_attachment_image().
 *
 * @return string
 */
function wp_kama_get_attachment_image_filter( $html, $attachment_id, $size, $icon, $attr ){

	// filter...
	return $html;
}
$html(строка)
HTML img element or empty string on failure.
$attachment_id(int)
Image attachment ID.
$size(строка|int[])
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
$icon(true|false)
Whether the image should be treated as an icon.
$attr(string[])
Array of attribute values for the image markup, keyed by attribute name. See wp_get_attachment_image().

Список изменений

С версии 5.6.0 Введена.

Где вызывается хук

wp_get_attachment_image()
wp_get_attachment_image
wp-includes/media.php 1163
return apply_filters( 'wp_get_attachment_image', $html, $attachment_id, $size, $icon, $attr );

Где используется хук в WordPress

Использование не найдено.