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
212
213           /**
214            * Filter the WP_Image_Editor instance for the image to be streamed to the browser.
215            *
216            * @since 3.5.0
217            *
218            * @param WP_Image_Editor $image   WP_Image_Editor instance.
219            * @param int             $post_id Post ID.
220            */
221           $image = apply_filters( 'image_editor_save_pre', $image, $post_id );
222
223           if ( is_wp_error( $image->stream( $mime_type ) ) )
224                return false;
225
226           return true;
227      } else {
228           _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
229
230           /**
 
Line Code
261  * @param WP_Image_Editor $image
262  * @param string $mime_type
263  * @param int $post_id
264  * @return boolean
265  */
266 function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
267      if ( $image instanceof WP_Image_Editor ) {
268
269           /** This filter is documented in wp-admin/includes/image-edit.php */
270           $image = apply_filters( 'image_editor_save_pre', $image, $post_id );
271
272           /**
273            * Filter whether to skip saving the image file.
274            *
275            * Returning a non-null value will short-circuit the save method,
276            * returning that value instead.
277            *
278            * @since 3.5.0
279            *