Make WordPress Core

Changeset 22538


Ignore:
Timestamp:
11/10/2012 08:42:27 PM (12 years ago)
Author:
ryan
Message:

Pass an attachment ID, not a file path, to _load_image_to_edit_path() from wp_crop_image(). This fixes handling of attachments that require url fopen to access the image.

Allow passing urls instead of just file paths to WP_Image_Editor_Imagick::load() and WP_Image_Editor_GD::load() so that attachments requiring URL fopen can be handled.

see #6821

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/image.php

    r22319 r22538  
    2323 * @return string|WP_Error|false New filepath on success, WP_Error or false on failure.
    2424 */
    25 function wp_crop_image( $src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
    26     if ( is_numeric( $src_file ) ) { // Handle int as attachment ID
    27         $src_file = get_attached_file( $src_file );
     25function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
     26    $src_file = $src;
     27    if ( is_numeric( $src ) ) { // Handle int as attachment ID
     28        $src_file = get_attached_file( $src );
     29
    2830        if ( ! file_exists( $src_file ) ) {
    2931            // If the file doesn't exist, attempt a url fopen on the src link.
    3032            // This can occur with certain file replication plugins.
    31             $src_file = _load_image_to_edit_path( $src_file, 'full' );
     33            $src_file = _load_image_to_edit_path( $src, 'full' );
    3234        }
    3335    }
  • trunk/wp-includes/class-wp-image-editor-gd.php

    r22510 r22538  
    5252            return true;
    5353
    54         if ( ! is_file( $this->file ) )
     54        if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
    5555            return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file );
    5656
  • trunk/wp-includes/class-wp-image-editor-imagick.php

    r22510 r22538  
    5353            return true;
    5454
    55         if ( ! is_file( $this->file ) )
     55        if ( ! is_file( $this->file ) && ! preg_match( '|^https?://|', $this->file ) )
    5656            return new WP_Error( 'error_loading_image', __('File doesn’t exist?'), $this->file );
    5757
Note: See TracChangeset for help on using the changeset viewer.