Ticket #26149: 26149.patch
| File 26149.patch, 4.8 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 ) … … 259 317 260 318 switch ( $mime_type ) { 261 319 case 'image/jpeg': 320 /** 321 * Alter the quality of the JPEG created by GD. 322 * 323 * @since 2.5.0 324 * 325 * @param int The quality of the JPG 326 * @param string The context of the filter 327 */ 262 328 return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) ); 263 329 case 'image/png': 264 330 return imagepng( $image, $filename ); … … 397 463 } 398 464 399 465 // image resource before applying the changes 400 if ( $image instanceof WP_Image_Editor ) 466 if ( $image instanceof WP_Image_Editor ) { 467 /** 468 * Filter the WP_Image_Editor instance before applying changes to the image. 469 * 470 * @since 3.5.0 471 * 472 * @param WP_Image_Editor $image WP_Image_Editor instance 473 * @param array $changes Array of change operations 474 */ 401 475 $image = apply_filters('wp_image_editor_before_change', $image, $changes); 402 elseif ( is_resource( $image ) ) 476 } elseif ( is_resource( $image ) ) { 477 /** 478 * Filter the GD image resource before applying changes to the image. 479 * 480 * @since 2.9.0 481 * 482 * @param resource $image GD image resource 483 * @param array $changes Array of change operations 484 */ 403 485 $image = apply_filters('image_edit_before_change', $image, $changes); 486 } 404 487 405 488 foreach ( $changes as $operation ) { 406 489 switch ( $operation->type ) { … … 450 533 */ 451 534 function stream_preview_image( $post_id ) { 452 535 $post = get_post( $post_id ); 536 /** This filter is documented in wp-admin/admin.php */ 453 537 @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) ); 454 538 455 539 $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) );