Ticket #26149: 26149.2.diff
| File 26149.2.diff, 4.5 KB (added by , 12 years ago) |
|---|
-
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 /** 207 * Filter the WP_Image_Editor instance for the image to be streamed to the browser. 208 * 209 * @since 3.5.0 210 * 211 * @param WP_Image_Editor $image WP_Image_Editor instance. 212 * @param int $post_id Post id. 213 */ 206 214 $image = apply_filters('image_editor_save_pre', $image, $post_id); 207 215 208 216 if ( is_wp_error( $image->stream( $mime_type ) ) ) … … 212 220 } else { 213 221 _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); 214 222 223 /** 224 * Filter the GD image resource to be streamed to the browser. 225 * 226 * @since 2.9.0 227 * 228 * @param resource $image Image resource to be streamed. 229 * @param int $post_id Post id. 230 */ 215 231 $image = apply_filters('image_save_pre', $image, $post_id); 216 217 232 switch ( $mime_type ) { 218 233 case 'image/jpeg': 219 234 header( 'Content-Type: image/jpeg' ); … … 241 256 */ 242 257 function wp_save_image_file( $filename, $image, $mime_type, $post_id ) { 243 258 if ( $image instanceof WP_Image_Editor ) { 259 /** 260 * Filter the WP_Image_Editor instance for the image to be saved. 261 * 262 * @since 3.5.0 263 * 264 * @param WP_Image_Editor $image WP_Image_Editor instance. 265 * @param int $post_id Post id. 266 */ 244 267 $image = apply_filters('image_editor_save_pre', $image, $post_id); 268 269 /** 270 * 271 * This filter changes the returned value of the function and returns 272 * the function before invoking the WP_Image_Editor::save method. 273 * 274 * @since 3.5.0 275 * 276 * @param Value for the function to return. 277 * @param string $filename Name of the file to be saved. 278 * @param WP_Image_Editor $image WP_Image_Editor instance. 279 * @param string $mime_type Image Mime Type. 280 * @param int $post_id Post id. 281 */ 245 282 $saved = apply_filters('wp_save_image_editor_file', null, $filename, $image, $mime_type, $post_id); 246 283 247 284 if ( null !== $saved ) … … 251 288 } else { 252 289 _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) ); 253 290 291 /** 292 * Filter the GD image resource to be saved. 293 * 294 * @since 2.9.0 295 * 296 * @param resource $image GD image resource to be saved. 297 * @param int $post_id Post id. 298 */ 254 299 $image = apply_filters('image_save_pre', $image, $post_id); 300 301 /** 302 * This filter changes the returned value of the function and returns 303 * the function before invoking the GD image creation functions. 304 * 305 * @since 2.9.0 306 * 307 * @param Value for the function to return. 308 * @param string $filename Name of the file to be saved. 309 * @param WP_Image_Editor $image WP_Image_Editor instance. 310 * @param string $mime_type Image Mime Type. 311 * @param int $post_id Post id. 312 */ 255 313 $saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id); 256 314 257 315 if ( null !== $saved ) … … 398 456 } 399 457 400 458 // image resource before applying the changes 401 if ( $image instanceof WP_Image_Editor ) 459 if ( $image instanceof WP_Image_Editor ) { 460 /** 461 * Filter the WP_Image_Editor instance before applying changes to the image. 462 * 463 * @since 3.5.0 464 * 465 * @param WP_Image_Editor $image WP_Image_Editor instance. 466 * @param array $changes Array of change operations. 467 */ 402 468 $image = apply_filters('wp_image_editor_before_change', $image, $changes); 403 elseif ( is_resource( $image ) ) 469 } elseif ( is_resource( $image ) ) { 470 /** 471 * Filter the GD image resource before applying changes to the image. 472 * 473 * @since 2.9.0 474 * 475 * @param resource $image GD image resource. 476 * @param array $changes Array of change operations. 477 */ 404 478 $image = apply_filters('image_edit_before_change', $image, $changes); 479 } 405 480 406 481 foreach ( $changes as $operation ) { 407 482 switch ( $operation->type ) { … … 451 526 */ 452 527 function stream_preview_image( $post_id ) { 453 528 $post = get_post( $post_id ); 529 /** This filter is documented in wp-admin/admin.php */ 454 530 @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); 455 531 456 532 $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) );