Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: image_downsize

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
189       * down-sizing the image, returning that value as output instead.
190       *
191       * @since 2.5.0
192       *
193       * @param bool         $downsize Whether to short-circuit the image downsize. Default false.
194       * @param int          $id       Attachment ID for image.
195       * @param array|string $size     Size of image. Image size or array of width and height values (in that order).
196       *                               Default 'medium'.
197       */
198      if ( $out = apply_filters( 'image_downsize', false, $id, $size ) ) {
199           return $out;
200      }
201
202      $img_url          = wp_get_attachment_url( $id );
203      $meta             = wp_get_attachment_metadata( $id );
204      $width            = $height = 0;
205      $is_intermediate  = false;
206      $img_url_basename = wp_basename( $img_url );
207
 
Line Code
3310           unset( $possible_sizes['full'] );
3311
3312           // Loop through all potential sizes that may be chosen. Try to do this with some efficiency.
3313           // First: run the image_downsize filter. If it returns something, we can use its data.
3314           // If the filter does not return something, then image_downsize() is just an expensive
3315           // way to check the image metadata, which we do second.
3316           foreach ( $possible_sizes as $size => $label ) {
3317
3318                /** This filter is documented in wp-includes/media.php */
3319                if ( $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ) ) {
3320                     if ( empty( $downsize[3] ) ) {
3321                          continue;
3322                     }
3323
3324                     $sizes[ $size ] = array(
3325                          'height'      => $downsize[2],
3326                          'width'       => $downsize[1],
3327                          'url'         => $downsize[0],
3328                          'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape',