Source View: image_editor_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.

  • Action hooks look like this: do_action( "hook_name" )
  • Filter hooks look like this: 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.

Source View

This hook occurs 2 times in this file.

Line Code
242
243           /**
244            * Filters the WP_Image_Editor instance for the image to be streamed to the browser.
245            *
246            * @since 3.5.0
247            *
248            * @param WP_Image_Editor $image         The image editor instance.
249            * @param int             $attachment_id The attachment post ID.
250            */
251           $image = apply_filters( 'image_editor_save_pre', $image, $attachment_id );
252
253           if ( is_wp_error( $image->stream( $mime_type ) ) )
254                return false;
255
256           return true;
257      } else {
258           _deprecated_argument( __FUNCTION__, '3.5.0', __( '$image needs to be an WP_Image_Editor object' ) );
259
260           /**
 
Line Code
291  * @param WP_Image_Editor $image
292  * @param string $mime_type
293  * @param int $post_id
294  * @return bool
295  */
296 function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
297      if ( $image instanceof WP_Image_Editor ) {
298
299           /** This filter is documented in wp-admin/includes/image-edit.php */
300           $image = apply_filters( 'image_editor_save_pre', $image, $post_id );
301
302           /**
303            * Filters whether to skip saving the image file.
304            *
305            * Returning a non-null value will short-circuit the save method,
306            * returning that value instead.
307            *
308            * @since 3.5.0
309            *