Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: image_save_pre

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
226           /**
227            * Filter the GD image resource to be streamed to the browser.
228            *
229            * @since 2.9.0
230            * @deprecated 3.5.0 Use image_editor_save_pre instead.
231            *
232            * @param resource $image   Image resource to be streamed.
233            * @param int      $post_id Post ID.
234            */
235           $image = apply_filters( 'image_save_pre', $image, $post_id );
236
237           switch ( $mime_type ) {
238                case 'image/jpeg':
239                     header( 'Content-Type: image/jpeg' );
240                     return imagejpeg( $image, null, 90 );
241                case 'image/png':
242                     header( 'Content-Type: image/png' );
243                     return imagepng( $image );
244                case 'image/gif':
 
Line Code
283
284           if ( null !== $saved )
285                return $saved;
286
287           return $image->save( $filename, $mime_type );
288      } else {
289           _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
290
291           /** This filter is documented in wp-admin/includes/image-edit.php */
292           $image = apply_filters( 'image_save_pre', $image, $post_id );
293
294           /**
295            * Filter whether to skip saving the image file.
296            *
297            * Returning a non-null value will short-circuit the save method,
298            * returning that value instead.
299            *
300            * @since 2.9.0
301            * @deprecated 3.5.0 Use wp_save_image_editor_file instead.