WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )apply_filters( "hook_name", "what_to_filter" ).Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 2 times in this file.
| Line | Code |
|---|---|
| 155 | * Passing a truthy value to the filter will effectively short-circuit |
| 156 | * down-sizing the image, returning that value as output instead. |
| 157 | * |
| 158 | * @since 2.5.0 |
| 159 | * |
| 160 | * @param bool $downsize Whether to short-circuit the image downsize. Default false. |
| 161 | * @param int $id Attachment ID for image. |
| 162 | * @param array|string $size Size of image, either array or string. Default 'medium'. |
| 163 | */ |
| 164 | if ( $out = apply_filters( 'image_downsize', false, $id, $size ) ) { |
| 165 | return $out; |
| 166 | } |
| 167 | |
| 168 | $img_url = wp_get_attachment_url($id); |
| 169 | $meta = wp_get_attachment_metadata($id); |
| 170 | $width = $height = 0; |
| 171 | $is_intermediate = false; |
| 172 | $img_url_basename = wp_basename($img_url); |
| 173 | |
| Line | Code |
| 2684 | unset( $possible_sizes['full'] ); |
| 2685 | |
| 2686 | // Loop through all potential sizes that may be chosen. Try to do this with some efficiency. |
| 2687 | // First: run the image_downsize filter. If it returns something, we can use its data. |
| 2688 | // If the filter does not return something, then image_downsize() is just an expensive |
| 2689 | // way to check the image metadata, which we do second. |
| 2690 | foreach ( $possible_sizes as $size => $label ) { |
| 2691 | |
| 2692 | /** This filter is documented in wp-includes/media.php */ |
| 2693 | if ( $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ) ) { |
| 2694 | if ( ! $downsize[3] ) |
| 2695 | continue; |
| 2696 | $sizes[ $size ] = array( |
| 2697 | 'height' => $downsize[2], |
| 2698 | 'width' => $downsize[1], |
| 2699 | 'url' => $downsize[0], |
| 2700 | 'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape', |
| 2701 | ); |
| 2702 | } elseif ( isset( $meta['sizes'][ $size ] ) ) { |