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
286           /**
287            * Filters the GD image resource to be streamed to the browser.
288            *
289            * @since 2.9.0
290            * @deprecated 3.5.0 Use image_editor_save_pre instead.
291            *
292            * @param resource $image         Image resource to be streamed.
293            * @param int      $attachment_id The attachment post ID.
294            */
295           $image = apply_filters( 'image_save_pre', $image, $attachment_id );
296
297           switch ( $mime_type ) {
298                case 'image/jpeg':
299                     header( 'Content-Type: image/jpeg' );
300                     return imagejpeg( $image, null, 90 );
301                case 'image/png':
302                     header( 'Content-Type: image/png' );
303                     return imagepng( $image );
304                case 'image/gif':
 
Line Code
347                return $saved;
348           }
349
350           return $image->save( $filename, $mime_type );
351      } else {
352           /* translators: 1: $image, 2: WP_Image_Editor */
353           _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( '%1$s needs to be a %2$s object.' ), '$image', 'WP_Image_Editor' ) );
354
355           /** This filter is documented in wp-admin/includes/image-edit.php */
356           $image = apply_filters( 'image_save_pre', $image, $post_id );
357
358           /**
359            * Filters whether to skip saving the image file.
360            *
361            * Returning a non-null value will short-circuit the save method,
362            * returning that value instead.
363            *
364            * @since 2.9.0
365            * @deprecated 3.5.0 Use wp_save_image_editor_file instead.