Ticket #26149: 26149.diff
| File 26149.diff, 5.3 KB (added by , 12 years ago) |
|---|
-
src/wp-admin/includes/image-edit.php
203 203 */ 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);207 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 ); 216 208 217 if ( is_wp_error( $image->stream( $mime_type ) ) ) 209 218 return false; 210 219 … … 212 221 } else { 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 hook 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 ) { 218 236 case 'image/jpeg': … … 241 259 */ 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);246 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 ); 281 247 282 if ( null !== $saved ) 248 283 return $saved; 249 284 … … 251 286 } else { 252 287 _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); 253 288 289 /** This filter is documented in wp-admin/includes/image-edit.php */ 254 290 $image = apply_filters('image_save_pre', $image, $post_id); 255 $saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id);256 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 the wp_save_image_editor_file hook 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 ); 308 257 309 if ( null !== $saved ) 258 310 return $saved; 259 311 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' ) ); 264 317 case 'image/png': … … 398 451 } 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 ) { 405 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 the wp_image_editor_before_change hook 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 } 478 406 479 foreach ( $changes as $operation ) { 407 480 switch ( $operation->type ) { 408 481 case 'rotate': … … 451 524 */ 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 456 531 $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) );