WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/11/2009 11:24:01 AM (11 years ago)
Author:
azaozz
Message:

Fix image meta after editing image, disable the Save button when no changes, fixes #11115

File:
1 edited

Legend:

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

    r11911 r12163  
    8989    $metadata = array();
    9090    if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) {
    91         $full_path_file = $file;
    92         $imagesize = getimagesize( $full_path_file );
     91        $imagesize = getimagesize( $file );
    9392        $metadata['width'] = $imagesize[0];
    9493        $metadata['height'] = $imagesize[1];
     
    9796
    9897        // Make the file path relative to the upload dir
    99         if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { // Get upload directory
    100             if ( 0 === strpos($file, $uploads['basedir']) ) {// Check that the upload base exists in the file path
    101                 $file = str_replace($uploads['basedir'], '', $file); // Remove upload dir from the file path
    102                 $file = ltrim($file, '/');
    103             }
    104         }
    105         $metadata['file'] = $file;
     98        $metadata['file'] = _wp_relative_upload_path($file);
    10699
    107100        // make thumbnails and other intermediate sizes
    108         $sizes = array('thumbnail', 'medium', 'large');
    109         $sizes = apply_filters('intermediate_image_sizes', $sizes);
     101        $sizes = apply_filters( 'intermediate_image_sizes', array('thumbnail', 'medium', 'large') );
    110102
    111103        foreach ($sizes as $size) {
    112             $resized = image_make_intermediate_size( $full_path_file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") );
     104            $resized = image_make_intermediate_size( $file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") );
    113105            if ( $resized )
    114106                $metadata['sizes'][$size] = $resized;
     
    116108
    117109        // fetch additional metadata from exif/iptc
    118         $image_meta = wp_read_image_metadata( $full_path_file );
    119         if ($image_meta)
     110        $image_meta = wp_read_image_metadata( $file );
     111        if ( $image_meta )
    120112            $metadata['image_meta'] = $image_meta;
    121113
Note: See TracChangeset for help on using the changeset viewer.