diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php index 784431e166..d2e67b0425 100644 --- a/wp-admin/admin-functions.php +++ b/wp-admin/admin-functions.php @@ -669,6 +669,8 @@ function wp_create_thumbnail($file, $max_side, $effect = '') { } } + } else { + $error = __('File not found'); } if (!empty ($error)) { diff --git a/wp-admin/image-uploading.php b/wp-admin/image-uploading.php index ad8f3638fa..4610790c38 100644 --- a/wp-admin/image-uploading.php +++ b/wp-admin/image-uploading.php @@ -135,9 +135,16 @@ $imagedata['height'] = $imagesize['1']; list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']); $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'"; $imagedata['file'] = $file; +$imagedata['thumb'] = "thumb-$filename"; -if ( false == add_post_meta($id, 'imagedata', $imagedata) ) - die("failed to add_post_meta"); +add_post_meta($id, 'imagedata', $imagedata); + +if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) { + if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 ) + $error = wp_create_thumbnail($file, 128); + elseif ( $imagedata['height'] > 96 ) + $error = wp_create_thumbnail($file, 96); +} header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&last=true"); die; @@ -192,24 +199,56 @@ $i = 0; $uwidth_sum = 0; $images_html = ''; $images_style = ''; +$images_script = ''; if ( count($images) > 0 ) { $images = array_slice( $images, 0, $num ); + $__delete = __('DELETE'); + $__subpost_on = __('SUBPOST ON'); + $__subpost_off = __('SUBPOST OFF'); + $__thumbnail_on = __('THUMBNAIL ON'); + $__thumbnail_off = __('THUMBNAIL OFF'); + $__no_thumbnail = __('THUMBNAIL'); + $__close = __('CLOSE'); + $__confirmdelete = __('Delete this photo from the server?'); + $__nothumb = __('There is no thumbnail associated with this photo.'); + $images_script .= "subposton = '$__subpost_on';\nsubpostoff = '$__subpost_off';\n"; + $images_script .= "thumbnailon = '$__thumbnail_on';\nthumbnailoff = '$__thumbnail_off';\n"; foreach ( $images as $key => $image ) { - $image = array_merge($image, get_post_meta($image['ID'], 'imagedata', true) ); + $meta = get_post_meta($image['ID'], 'imagedata', true); + if (!is_array($meta)) { + wp_delete_object($image['ID']); + continue; + } + $image = array_merge($image, $meta); + if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) { + $src = str_replace(basename($image['guid']), '', $image['guid']) . $image['thumb']; + $images_script .= "src".$i."a = '$src';\nsrc".$i."b = '".$image['guid']."';\n"; + $thumb = 'true'; + $thumbtext = $__thumbnail_on; + } else { + $src = $image['guid']; + $thumb = 'false'; + $thumbtext = $__no_thumbnail; + } list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']); - $uwidth_sum += 128; //$image['uwidth']; + $height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"'; + $uwidth_sum += 128; $xpadding = (128 - $image['uwidth']) / 2; $ypadding = (96 - $image['uheight']) / 2; $object = $image['ID']; $images_style .= "#target$i img { padding: {$ypadding}px {$xpadding}px; }\n"; + $href = get_subpost_link($object); + $images_script .= "href".$i."a = '$href';\nhref".$i."b = '{$image['guid']}';\n"; $images_html .= << - - {$image[ + + {$image[ HERE; @@ -231,6 +270,9 @@ die('This script was not meant to be called directly.');