From 56777d417dd3fefd42e44db4f60377709fccdf5a Mon Sep 17 00:00:00 2001 From: donncha Date: Fri, 18 Nov 2005 13:47:42 +0000 Subject: WP Merge git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@440 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-inst/wp-admin/inline-uploading.php | 45 +++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) (limited to 'wp-inst/wp-admin/inline-uploading.php') diff --git a/wp-inst/wp-admin/inline-uploading.php b/wp-inst/wp-admin/inline-uploading.php index 25251bb..eaa8d16 100644 --- a/wp-inst/wp-admin/inline-uploading.php +++ b/wp-inst/wp-admin/inline-uploading.php @@ -80,7 +80,7 @@ $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'"; $imagedata['file'] = $file; $imagedata['thumb'] = "thumb-$filename"; -add_post_meta($id, 'imagedata', $imagedata); +add_post_meta($id, '_wp_attachment_metadata', $imagedata); if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) { if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 ) @@ -124,7 +124,10 @@ if ( '' == $sort ) $images = $wpdb->get_results("SELECT ID, post_date, post_title, guid FROM $wpdb->posts WHERE post_status = 'attachment' AND left(post_mime_type, 5) = 'image' $and_post ORDER BY $sort LIMIT $start, $double", ARRAY_A); -if ( count($images) > $num ) { +if ( count($images) == 0 ) { + header("Location: ".basename(__FILE__)."?post=$post&action=upload"); + die; +} elseif ( count($images) > $num ) { $next = $start + count($images) - $num; } else { $next = false; @@ -138,7 +141,6 @@ if ( $start > 0 ) { $back = false; } -$i = 0; $uwidth_sum = 0; $images_html = ''; $images_style = ''; @@ -157,15 +159,20 @@ if ( count($images) > 0 ) { $images_script .= "attachmenton = '$__attachment_on';\nattachmentoff = '$__attachment_off';\n"; $images_script .= "thumbnailon = '$__thumbnail_on';\nthumbnailoff = '$__thumbnail_off';\n"; foreach ( $images as $key => $image ) { - $meta = get_post_meta($image['ID'], 'imagedata', true); + $attachment_ID = $image['ID']; + $meta = get_post_meta($attachment_ID, '_wp_attachment_metadata', true); if (!is_array($meta)) { - wp_delete_attachment($image['ID']); - continue; + $meta = get_post_meta($attachment_ID, 'imagedata', true); // Try 1.6 Alpha meta key + if (!is_array($meta)) { + continue; + } else { + add_post_meta($attachment_ID, '_wp_attachment_metadata', $meta); + } } $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"; + $images_script .= "src".$attachment_ID."a = '$src';\nsrc".$attachment_ID."b = '".$image['guid']."';\n"; $thumb = 'true'; $thumbtext = $__thumbnail_on; } else { @@ -178,24 +185,22 @@ if ( count($images) > 0 ) { $uwidth_sum += 128; $xpadding = (128 - $image['uwidth']) / 2; $ypadding = (96 - $image['uheight']) / 2; - $attachment = $image['ID']; - $images_style .= "#target$i img { padding: {$ypadding}px {$xpadding}px; }\n"; - $href = get_attachment_link($attachment); - $images_script .= "href".$i."a = '$href';\nhref".$i."b = '{$image['guid']}';\n"; + $images_style .= "#target{$attachment_ID} img { padding: {$ypadding}px {$xpadding}px; }\n"; + $href = get_attachment_link($attachment_ID); + $images_script .= "href{$attachment_ID}a = '$href';\nhref{$attachment_ID}b = '{$image['guid']}';\n"; $images_html .= " -
-