Thumbnail and exif fixes from DD32. see #7622

git-svn-id: http://svn.automattic.com/wordpress/trunk@8879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-09-13 18:04:20 +00:00
parent 8db1601dd7
commit 2c92ac6f0b

View File

@ -88,11 +88,13 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
$metadata = array();
if ( preg_match('!^image/!', get_post_mime_type( $attachment )) && file_is_displayable_image($file) ) {
$imagesize = getimagesize( $file );
$full_path_file = $file;
$imagesize = getimagesize( $full_path_file );
$metadata['width'] = $imagesize[0];
$metadata['height'] = $imagesize[1];
list($uwidth, $uheight) = wp_shrink_dimensions($metadata['width'], $metadata['height']);
$metadata['hwstring_small'] = "height='$uheight' width='$uwidth'";
// Make the file path relative to the upload dir
if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) { // Get upload directory
if ( 0 === strpos($file, $uploads['basedir']) ) {// Check that the upload base exists in the file path
@ -107,13 +109,13 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) {
$sizes = apply_filters('intermediate_image_sizes', $sizes);
foreach ($sizes as $size) {
$resized = image_make_intermediate_size( $file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") );
$resized = image_make_intermediate_size( $full_path_file, get_option("{$size}_size_w"), get_option("{$size}_size_h"), get_option("{$size}_crop") );
if ( $resized )
$metadata['sizes'][$size] = $resized;
}
// fetch additional metadata from exif/iptc
$image_meta = wp_read_image_metadata( $file );
$image_meta = wp_read_image_metadata( $full_path_file );
if ($image_meta)
$metadata['image_meta'] = $image_meta;