wp-includes/media.php:1058$attachment_idint$sizestring|int[]optional'thumbnail'$iconbooloptionalfalsearray|false$0string
$1int
$2int
$3bool
2 hooks fire while wp_get_attachment_image_src() runs, in this order:
Filters the attachment image source result.
function wp_get_attachment_image_src( $attachment_id, $size = 'thumbnail', $icon = false ) { // Get a thumbnail or intermediate image if there is one. $image = image_downsize( $attachment_id, $size ); if ( ! $image ) { $src = false; $width = 0; $height = 0; if ( $icon ) { $src = wp_mime_type_icon( $attachment_id, '.svg' ); if ( $src ) { /** 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 ); $image_size = wp_getimagesize( $src_file ); if ( is_array( $image_size ) ) { $width = $image_size[0]; $height = $image_size[1]; } $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 { $image_size = wp_getimagesize( $src_file ); if ( is_array( $image_size ) ) { $width = $image_size[0]; $height = $image_size[1]; } } } } if ( $src && $width && $height ) { $image = array( $src, $width, $height, false ); } } /** * Filters the attachment image source result. * * @since 4.3.0 * * @param array|false $image { * Array of image data, or boolean false if no image is available. * * @type string $0 Image source URL. * @type int $1 Image width in pixels. * @type int $2 Image height in pixels. * @type bool $3 Whether the image is a resized image. * } * @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. */ $source = apply_filters( 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon ); if ( is_array( $source ) && isset( $source[0] ) && is_string( $source[0] ) ) { return array( $source[0], (int) ( $source[1] ?? 0 ), (int) ( $source[2] ?? 0 ), (bool) ( $source[3] ?? false ), ); } return false;}Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/media.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.