wp_get_attachment_image_src

Filters the image src result.

Description

apply_filters( 'wp_get_attachment_image_src', (array|false) $image, (int) $attachment_id, (string|array) $size, (bool) $icon ); 

Parameters (4)

0. $image (array|false)
Either array with src, width & height, icon src, or false.
1. $attachment_id (int)
Image attachment ID.
2. $size (string|array)
Size of image. Image size or array of width and height values (in that order). Default thumbnail..
3. $icon (bool)
Whether the image should be treated as an icon. Default false.

Usage

To run the hook, copy the example below.
  1. $image = apply_filters( 'wp_get_attachment_image_src', $image, $attachment_id, $size, $icon ); 
  2.  
  3. if ( !empty( $image ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_get_attachment_image_src callback 
  2. function filter_wp_get_attachment_image_src( $image, $attachment_id, $size, $icon ) { 
  3. // make filter magic happen here... 
  4. return $image
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_get_attachment_image_src', 'filter_wp_get_attachment_image_src', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_get_attachment_image_src', 'filter_wp_get_attachment_image_src', 10, 4 ); 

Defined (1)

The filter is defined in the following location(s).

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