diff options
Diffstat (limited to 'wp-inst/wp-admin/inline-uploading.php')
| -rw-r--r-- | wp-inst/wp-admin/inline-uploading.php | 45 |
1 files changed, 25 insertions, 20 deletions
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 .= "
-<div id='target$i' class='imagewrap left'>
- <div id='popup$i' class='popup'>
- <a id=\"L$i\" onclick=\"toggleLink($i);return false;\" href=\"javascript:void();\">$__attachment_on</a>
- <a id=\"I$i\" onclick=\"if($thumb)toggleImage($i);else alert('$__nothumb');return false;\" href=\"javascript:void();\">$thumbtext</a>
- <a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&attachment=$attachment&all=$all&start=$start&post=$post\">$__delete</a>
+<div id='target{$attachment_ID}' class='imagewrap left'>
+ <div id='popup{$attachment_ID}' class='popup'>
+ <a id=\"L{$attachment_ID}\" onclick=\"toggleLink({$attachment_ID});return false;\" href=\"javascript:void();\">$__attachment_on</a>
+ <a id=\"I{$attachment_ID}\" onclick=\"if($thumb)toggleImage({$attachment_ID});else alert('$__nothumb');return false;\" href=\"javascript:void();\">$thumbtext</a>
+ <a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&attachment={$attachment_ID}&all=$all&start=$start&post=$post\">$__delete</a>
<a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
</div>
- <a id=\"link$i\" class=\"imagelink\" href=\"$href\" onclick=\"imagePopup($i);return false;\" title=\"{$image['post_title']}\">
- <img id='image$i' src='$src' alt='{$image['post_title']}' $height_width />
+ <a id=\"{$attachment_ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"imagePopup({$attachment_ID});return false;\" title=\"{$image['post_title']}\">
+ <img id=\"image{$attachment_ID}\" src=\"$src\" alt=\"{$attachment_ID}\" $height_width />
</a>
</div>
";
- $i++;
}
}
@@ -245,7 +250,7 @@ function init() { popup = false;
}
function toggleLink(n) {
- o=document.getElementById('link'+n);
+ o=document.getElementById(n);
oi=document.getElementById('L'+n);
if ( oi.innerHTML == attachmenton ) {
o.href = eval('href'+n+'b');
|
