wp_get_attachment_image_attributes хук-фильтрWP 2.8.0

Filters the list of attachment image attributes.

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

add_filter( 'wp_get_attachment_image_attributes', 'wp_kama_get_attachment_image_attributes_filter', 10, 3 );

/**
 * Function for `wp_get_attachment_image_attributes` filter-hook.
 * 
 * @param string[]     $attr       Array of attribute values for the image markup, keyed by attribute name. See wp_get_attachment_image().
 * @param WP_Post      $attachment Image attachment post.
 * @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).
 *
 * @return string[]
 */
function wp_kama_get_attachment_image_attributes_filter( $attr, $attachment, $size ){

	// filter...
	return $attr;
}
$attr(string[])
Array of attribute values for the image markup, keyed by attribute name. See wp_get_attachment_image().
$attachment(WP_Post)
Image attachment post.
$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).

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

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

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

wp_get_attachment_image()
wp_get_attachment_image_attributes
wp-includes/media.php 1149
$attr = apply_filters( 'wp_get_attachment_image_attributes', $attr, $attachment, $size );

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

wp-includes/media.php 2278
add_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' );
wp-includes/media.php 2291
remove_filter( 'wp_get_attachment_image_attributes', '_wp_post_thumbnail_class_filter' );