Make WordPress Core

Ticket #26149: 26149.diff

File 26149.diff, 5.3 KB (added by DrewAPicture, 12 years ago)

3rd pass

  • src/wp-admin/includes/image-edit.php

     
    203203 */
    204204function wp_stream_image( $image, $mime_type, $post_id ) {
    205205        if ( $image instanceof WP_Image_Editor ) {
    206                 $image = apply_filters('image_editor_save_pre', $image, $post_id);
    207206
     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
    208217                if ( is_wp_error( $image->stream( $mime_type ) ) )
    209218                        return false;
    210219
     
    212221        } else {
    213222                _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
    214223
    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 );
    216234
    217235                switch ( $mime_type ) {
    218236                        case 'image/jpeg':
     
    241259 */
    242260function wp_save_image_file( $filename, $image, $mime_type, $post_id ) {
    243261        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);
    246262
     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
    247282                if ( null !== $saved )
    248283                        return $saved;
    249284
     
    251286        } else {
    252287                _deprecated_argument( __FUNCTION__, '3.5', __( '$image needs to be an WP_Image_Editor object' ) );
    253288
     289                /** This filter is documented in wp-admin/includes/image-edit.php */
    254290                $image = apply_filters('image_save_pre', $image, $post_id);
    255                 $saved = apply_filters('wp_save_image_file', null, $filename, $image, $mime_type, $post_id);
    256291
     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
    257309                if ( null !== $saved )
    258310                        return $saved;
    259311
    260312                switch ( $mime_type ) {
    261313                        case 'image/jpeg':
     314
    262315                                /** This filter is documented in wp-includes/class-wp-image-editor.php */
    263316                                return imagejpeg( $image, $filename, apply_filters( 'jpeg_quality', 90, 'edit_image' ) );
    264317                        case 'image/png':
     
    398451        }
    399452
    400453        // 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 ) {
    405455
     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
    406479        foreach ( $changes as $operation ) {
    407480                switch ( $operation->type ) {
    408481                        case 'rotate':
     
    451524 */
    452525function stream_preview_image( $post_id ) {
    453526        $post = get_post( $post_id );
     527
     528        /** This filter is documented in wp-admin/admin.php */
    454529        @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', WP_MAX_MEMORY_LIMIT ) );
    455530
    456531        $img = wp_get_image_editor( _load_image_to_edit_path( $post_id ) );