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 |
|---|---|
| 133 | * @param array|string $size Optional, default is 'medium'. Size of image, either array or string. |
| 134 | * @return bool|array False on failure, array on success. |
| 135 | */ |
| 136 | function image_downsize($id, $size = 'medium') { |
| 137 | |
| 138 | if ( !wp_attachment_is_image($id) ) |
| 139 | return false; |
| 140 | |
| 141 | // plugins can use this to provide resize services |
| 142 | if ( $out = apply_filters( 'image_downsize', false, $id, $size ) ) |
| 143 | return $out; |
| 144 | |
| 145 | $img_url = wp_get_attachment_url($id); |
| 146 | $meta = wp_get_attachment_metadata($id); |
| 147 | $width = $height = 0; |
| 148 | $is_intermediate = false; |
| 149 | $img_url_basename = wp_basename($img_url); |
| 150 | |
| 151 | // try for a new style intermediate size |
| Line | Code |
| 1752 | 'full' => __('Full Size'), |
| 1753 | ) ); |
| 1754 | unset( $possible_sizes['full'] ); |
| 1755 | |
| 1756 | // Loop through all potential sizes that may be chosen. Try to do this with some efficiency. |
| 1757 | // First: run the image_downsize filter. If it returns something, we can use its data. |
| 1758 | // If the filter does not return something, then image_downsize() is just an expensive |
| 1759 | // way to check the image metadata, which we do second. |
| 1760 | foreach ( $possible_sizes as $size => $label ) { |
| 1761 | if ( $downsize = apply_filters( 'image_downsize', false, $attachment->ID, $size ) ) { |
| 1762 | if ( ! $downsize[3] ) |
| 1763 | continue; |
| 1764 | $sizes[ $size ] = array( |
| 1765 | 'height' => $downsize[2], |
| 1766 | 'width' => $downsize[1], |
| 1767 | 'url' => $downsize[0], |
| 1768 | 'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape', |
| 1769 | ); |
| 1770 | } elseif ( isset( $meta['sizes'][ $size ] ) ) { |