wp_get_attachment_image_src
Filter HookDescription
Filters the attachment image source result. }Hook Information
File Location |
wp-includes/media.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1024 |
Hook Parameters
Type | Name | Description |
---|---|---|
array|false
|
$image
|
{ Array of image data, or boolean false if no image is available. |
int
|
$attachment_id
|
Image attachment ID. |
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). |
bool
|
$icon
|
Whether the image should be treated as an icon. |
Usage Examples
Basic Usage
<?php
// Hook into wp_get_attachment_image_src
add_filter('wp_get_attachment_image_src', 'my_custom_filter', 10, 4);
function my_custom_filter($image, $attachment_id, $size, $icon) {
// Your custom filtering logic here
return $image;
}
Source Code Context
wp-includes/media.php:1024
- How this hook is used in WordPress core
<?php
1019 * @param int $attachment_id Image attachment ID.
1020 * @param string|int[] $size Requested image size. Can be any registered image size name, or
1021 * an array of width and height values in pixels (in that order).
1022 * @param bool $icon Whether the image should be treated as an icon.
1023 */
1024 return apply_filters( 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon );
1025 }
1026
1027 /**
1028 * Gets an HTML img element representing an image attachment.
1029 *
PHP Documentation
<?php
/**
* 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.
*/
Quick Info
- Hook Type: Filter
- Parameters: 4
- File: wp-includes/media.php
Related Hooks
Related hooks will be displayed here in future updates.