wp_save_image_file
Filters whether to skip saving the image file.
Description
apply_filters( 'wp_save_image_file', (null) $null, (string) $filename, (WP_Image_Editor) $image, (string) $mime_type, (int) $post_id );
Returning a non-null value will short-circuit the save method, returning that value instead.
Parameters (5)
- 0. $null (null) =>
null
- Value to return instead of saving. Default null.
- 1. $filename (string)
- Name of the file to be saved.
- 2. $image (WP_Image_Editor)
-
WP_Image_Editor
instance. - 3. $mime_type (string)
- Image mime type.
- 4. $post_id (int)
- The post id.
Usage
- To run the hook, copy the example below.
- $null = apply_filters( 'wp_save_image_file', $null, $filename, $image, $mime_type, $post_id );
- if ( !empty( $null ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the wp_save_image_file callback
- function filter_wp_save_image_file( $null, $filename, $image, $mime_type, $post_id ) {
- // make filter magic happen here...
- return $null;
- };
- // add the filter
- add_filter( 'wp_save_image_file', 'filter_wp_save_image_file', 10, 5 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( 'wp_save_image_file', 'filter_wp_save_image_file', 10, 5 );
Defined (1)
The filter is defined in the following location(s).
- /wp-admin/includes/image-edit.php
- $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id );