wp_get_attachment_image_src хук-фильтрWP 4.3.0

Filters the attachment image source result.


add_filter( 'wp_get_attachment_image_src', 'wp_kama_wp_get_attachment_image_src_filter', 10, 4 );
function wp_kama_wp_get_attachment_image_src_filter( $image, $attachment_id, $size, $icon ){
	// filter...

	return $image;

Array of image data, or boolean false if no image is available.

  • 0(строка)
    Image source URL.

  • 1(int)
    Image width in pixels.

  • 2(int)
    Image height in pixels.

  • 3(true|false)
    Whether the image is a resized image.
Image attachment ID.
Requested image size. Can be any registered image size name, or an array of width and height values in pixels (in that order).
Whether the image should be treated as an icon.

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

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

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

wp-includes/media.php 992
return apply_filters( 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon );

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

wp-includes/blocks/site-logo.php 24
add_filter( 'wp_get_attachment_image_src', $adjust_width_height_filter );
wp-includes/blocks/site-logo.php 28
remove_filter( 'wp_get_attachment_image_src', $adjust_width_height_filter );