Changeset 27357
- Timestamp:
- 03/02/2014 08:55:10 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/image-edit.php
r26648 r27357 204 204 function wp_stream_image( $image, $mime_type, $post_id ) { 205 205 if ( $image instanceof WP_Image_Editor ) { 206 $image = apply_filters('image_editor_save_pre', $image, $post_id); 206 207 /** 208 * Filter the WP_Image_Editor instance for the image to be streamed to the browser. 209 * 210 * @since 3.5.0 211 * 212 * @param WP_Image_Editor $image WP_Image_Editor instance. 213 * @param int $post_id Post ID. 214 */ 215 $image = apply_filters( 'image_editor_save_pre', $image, $post_id ); 207 216 208 217 if ( is_wp_error( $image->stream( $mime_type ) ) ) … … 213 222 _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); 214 223 215 $image = apply_filters('image_save_pre', $image, $post_id); 224 /** 225 * Filter the GD image resource to be streamed to the browser. 226 * 227 * @since 2.9.0 228 * @deprecated 3.5.0 Use image_editor_save_pre instead. 229 * 230 * @param resource $image Image resource to be streamed. 231 * @param int $post_id Post ID. 232 */ 233 $image = apply_filters( 'image_save_pre', $image, $post_id ); 216 234 217 235 switch ( $mime_type ) { … … 242 260 function wp_save_image_file( $filename, $image, $mime_type, $post_id ) { 243 261 if ( $image instanceof WP_Image_Editor ) { 244 $image = apply_filters('image_editor_save_pre', $image, $post_id); 245 $saved = apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id); 262 263 /** This filter is documented in wp-admin/includes/image-edit.php */ 264 $image = apply_filters( 'image_editor_save_pre', $image, $post_id ); 265 266 /** 267 * Filter whether to skip saving the image file. 268 * 269 * Returning a non-null value will short-circuit the save method, 270 * returning that value instead. 271 * 272 * @since 3.5.0 273 * 274 * @param mixed $override Value to return instead of saving. Default null. 275 * @param string $filename Name of the file to be saved. 276 * @param WP_Image_Editor $image WP_Image_Editor instance. 277 * @param string $mime_type Image mime type. 278 * @param int $post_id Post ID. 279 */ 280 $saved = apply_filters( 'wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id ); 246 281 247 282 if ( null !== $saved ) … … 252 287 _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); 253 288 254 $image = apply_filters('image_save_pre', $image, $post_id); 255 $saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id); 289 /** This filter is documented in wp-admin/includes/image-edit.php */ 290 $image = apply_filters( 'image_save_pre', $image, $post_id ); 291 292 /** 293 * Filter whether to skip saving the image file. 294 * 295 * Returning a non-null value will short-circuit the save method, 296 * returning that value instead. 297 * 298 * @since 2.9.0 299 * @deprecated 3.5.0 Use wp_save_image_editor_file instead. 300 * 301 * @param mixed $override Value to return instead of saving. Default null. 302 * @param string $filename Name of the file to be saved. 303 * @param WP_Image_Editor $image WP_Image_Editor instance. 304 * @param string $mime_type Image mime type. 305 * @param int $post_id Post ID. 306 */ 307 $saved = apply_filters( 'wp_save_image_file', null, $filename, $image, $mime_type, $post_id ); 256 308 257 309 if ( null !== $saved ) … … 260 312 switch ( $mime_type ) { 261 313 case 'image/jpeg': 314 262 315 /** This filter is documented in wp-includes/class-wp-image-editor.php */ 263 316 return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) ); … … 399 452 400 453 // image resource before applying the changes 401 if ( $image instanceof WP_Image_Editor ) 402 $image = apply_filters('wp_image_editor_before_change', $image, $changes); 403 elseif ( is_resource( $image ) ) 404 $image = apply_filters('image_edit_before_change', $image, $changes); 454 if ( $image instanceof WP_Image_Editor ) { 455 456 /** 457 * Filter the WP_Image_Editor instance before applying changes to the image. 458 * 459 * @since 3.5.0 460 * 461 * @param WP_Image_Editor $image WP_Image_Editor instance. 462 * @param array $changes Array of change operations. 463 */ 464 $image = apply_filters( 'wp_image_editor_before_change', $image, $changes ); 465 } elseif ( is_resource( $image ) ) { 466 467 /** 468 * Filter the GD image resource before applying changes to the image. 469 * 470 * @since 2.9.0 471 * @deprecated 3.5.0 Use wp_image_editor_before_change instead. 472 * 473 * @param resource $image GD image resource. 474 * @param array $changes Array of change operations. 475 */ 476 $image = apply_filters( 'image_edit_before_change', $image, $changes ); 477 } 405 478 406 479 foreach ( $changes as $operation ) { … … 452 525 function stream_preview_image( $post_id ) { 453 526 $post = get_post( $post_id ); 527 528 /** This filter is documented in wp-admin/admin.php */ 454 529 @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); 455 530 … … 501 576 // delete only if it's edited image 502 577 if ( preg_match('/-e[0-9]{13}\./', $parts['basename']) ) { 578 503 579 /** This filter is documented in wp-admin/custom-header.php */ 504 $delpath = apply_filters( 'wp_delete_file', $file);580 $delpath = apply_filters( 'wp_delete_file', $file ); 505 581 @unlink($delpath); 506 582 } … … 726 802 727 803 if ( $delete ) { 804 728 805 /** This filter is documented in wp-admin/custom-header.php */ 729 $delpath = apply_filters( 'wp_delete_file', $new_path);806 $delpath = apply_filters( 'wp_delete_file', $new_path ); 730 807 @unlink( $delpath ); 731 808 }
Note: See TracChangeset
for help on using the changeset viewer.