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 |
|---|---|
| 198 | * down-sizing the image, returning that value instead. |
| 199 | * |
| 200 | * @since 2.5.0 |
| 201 | * |
| 202 | * @param bool|array $downsize Whether to short-circuit the image downsize. |
| 203 | * @param int $id Attachment ID for image. |
| 204 | * @param string|int[] $size Requested image size. Can be any registered image size name, or |
| 205 | * an array of width and height values in pixels (in that order). |
| 206 | */ |
| 207 | $out = apply_filters( 'image_downsize', false, $id, $size ); |
| 208 | |
| 209 | if ( $out ) { |
| 210 | return $out; |
| 211 | } |
| 212 | |
| 213 | $img_url = wp_get_attachment_url( $id ); |
| 214 | $meta = wp_get_attachment_metadata( $id ); |
| 215 | $width = 0; |
| 216 | $height = 0; |
| Line | Code |
| 4228 | /* |
| 4229 | * Loop through all potential sizes that may be chosen. Try to do this with some efficiency. |
| 4230 | * First: run the image_downsize filter. If it returns something, we can use its data. |
| 4231 | * If the filter does not return something, then image_downsize() is just an expensive way |
| 4232 | * to check the image metadata, which we do second. |
| 4233 | */ |
| 4234 | foreach ( $possible_sizes as $size => $label ) { |
| 4235 | |
| 4236 | /** This filter is documented in wp-includes/media.php */ |
| 4237 | $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ); |
| 4238 | |
| 4239 | if ( $downsize ) { |
| 4240 | if ( empty( $downsize[3] ) ) { |
| 4241 | continue; |
| 4242 | } |
| 4243 | |
| 4244 | $sizes[ $size ] = array( |
| 4245 | 'height' => $downsize[2], |
| 4246 | 'width' => $downsize[1], |