Make WordPress Core

Ticket #3596: 3596b.diff

File 3596b.diff, 1.6 KB (added by mdawaffe, 20 years ago)
  • wp-admin/upload-functions.php

     
    33        global $post;
    44        $id = get_the_ID();
    55        $attachment_data = wp_get_attachment_metadata( $id );
     6        $is_image = (int) wp_attachment_is_image();
     7        if ( !isset($attachment_data['width']) && $is_image ) {
     8                if ( $image_data = getimagesize( get_attached_file( $id ) ) ) {
     9                        $attachment_data['width'] = $image_data[0];
     10                        $attachment_data['height'] = $image_data[1];
     11                        wp_update_attachment_metadata( $id, $attachment_data );
     12                }
     13        }
    614        if ( isset($attachment_data['width']) )
    715                list($width,$height) = wp_shrink_dimensions($attachment_data['width'], $attachment_data['height'], 171, 128);
     16               
    817        ob_start();
    918                the_title();
    1019                $post_title = attribute_escape(ob_get_contents());
    … …  
    4352                $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-$id' id='attachment-thumb-url-$id' value='$thumb_rel' />\n";
    4453                $r .= "\t\t\t\t<input type='hidden' name='attachment-thumb-url-base-$id' id='attachment-thumb-url-base-$id' value='$thumb_base' />\n";
    4554        }
    46         $is_image = (int) wp_attachment_is_image();
     55
    4756        $r .= "\t\t\t\t<input type='hidden' name='attachment-is-image-$id' id='attachment-is-image-$id' value='$is_image' />\n";
     57
    4858        if ( isset($width) ) {
    4959                $r .= "\t\t\t\t<input type='hidden' name='attachment-width-$id' id='attachment-width-$id' value='$width' />\n";
    5060                $r .= "\t\t\t\t<input type='hidden' name='attachment-height-$id' id='attachment-height-$id' value='$height' />\n";