Make WordPress Core


Ignore:
Timestamp:
11/18/2005 09:25:47 AM (21 years ago)
Author:
ryan
Message:

Attachment cleanups from skeltoac. fixes #1870

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/inline-uploading.php

    r3126 r3145  
    7878$imagedata['thumb'] = "thumb-$filename";
    7979
    80 add_post_meta($id, 'imagedata', $imagedata);
     80add_post_meta($id, '_wp_attachment_metadata', $imagedata);
    8181
    8282if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
     
    136136}
    137137
    138 $i = 0;
    139138$uwidth_sum = 0;
    140139$images_html = '';
     
    155154        $images_script .= "thumbnailon = '$__thumbnail_on';\nthumbnailoff = '$__thumbnail_off';\n";
    156155        foreach ( $images as $key => $image ) {
    157                 $meta = get_post_meta($image['ID'], 'imagedata', true);
     156                $attachment_ID = $image['ID'];
     157                $meta = get_post_meta($attachment_ID, '_wp_attachment_metadata', true);
    158158                if (!is_array($meta)) {
    159                         wp_delete_attachment($image['ID']);
    160                         continue;
     159                        $meta = get_post_meta($attachment_ID, 'imagedata', true); // Try 1.6 Alpha meta key
     160                        if (!is_array($meta)) {
     161                                continue;
     162                        } else {
     163                                add_post_meta($attachment_ID, '_wp_attachment_metadata', $meta);
     164                        }
    161165                }
    162166                $image = array_merge($image, $meta);
    163167                if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
    164168                        $src = str_replace(basename($image['guid']), '', $image['guid']) . $image['thumb'];
    165                         $images_script .= "src".$i."a = '$src';\nsrc".$i."b = '".$image['guid']."';\n";
     169                        $images_script .= "src".$attachment_ID."a = '$src';\nsrc".$attachment_ID."b = '".$image['guid']."';\n";
    166170                        $thumb = 'true';
    167171                        $thumbtext = $__thumbnail_on;
     
    176180                $xpadding = (128 - $image['uwidth']) / 2;
    177181                $ypadding = (96 - $image['uheight']) / 2;
    178                 $attachment = $image['ID'];
    179                 $images_style .= "#target$i img { padding: {$ypadding}px {$xpadding}px; }\n";
    180                 $href = get_attachment_link($attachment);
    181                 $images_script .= "href".$i."a = '$href';\nhref".$i."b = '{$image['guid']}';\n";
     182                $images_style .= "#target{$attachment_ID} img { padding: {$ypadding}px {$xpadding}px; }\n";
     183                $href = get_attachment_link($attachment_ID);
     184                $images_script .= "href{$attachment_ID}a = '$href';\nhref{$attachment_ID}b = '{$image['guid']}';\n";
    182185                $images_html .= "
    183 <div id='target$i' class='imagewrap left'>
    184         <div id='popup$i' class='popup'>
    185                 <a id=\"L$i\" onclick=\"toggleLink($i);return false;\" href=\"javascript:void();\">$__attachment_on</a>
    186                 <a id=\"I$i\" onclick=\"if($thumb)toggleImage($i);else alert('$__nothumb');return false;\" href=\"javascript:void();\">$thumbtext</a>
    187                 <a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&amp;attachment=$attachment&amp;all=$all&amp;start=$start&amp;post=$post\">$__delete</a>
     186<div id='target{$attachment_ID}' class='imagewrap left'>
     187        <div id='popup{$attachment_ID}' class='popup'>
     188                <a id=\"L{$attachment_ID}\" onclick=\"toggleLink({$attachment_ID});return false;\" href=\"javascript:void();\">$__attachment_on</a>
     189                <a id=\"I{$attachment_ID}\" onclick=\"if($thumb)toggleImage({$attachment_ID});else alert('$__nothumb');return false;\" href=\"javascript:void();\">$thumbtext</a>
     190                <a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&amp;attachment={$attachment_ID}&amp;all=$all&amp;start=$start&amp;post=$post\">$__delete</a>
    188191                <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
    189192        </div>
    190         <a id=\"link$i\" class=\"imagelink\" href=\"$href\" onclick=\"imagePopup($i);return false;\" title=\"{$image['post_title']}\">         
    191                 <img id='image$i' src='$src' alt='{$image['post_title']}' $height_width />
     193        <a id=\"{$attachment_ID}\" rel=\"attachment\" class=\"imagelink\" href=\"$href\" onclick=\"imagePopup({$attachment_ID});return false;\" title=\"{$image['post_title']}\">               
     194                <img id=\"image{$attachment_ID}\" src=\"$src\" alt=\"{$attachment_ID}\" $height_width />
    192195        </a>
    193196</div>
    194197";
    195                 $i++;
    196198        }
    197199}
     
    243245}
    244246function toggleLink(n) {
    245         o=document.getElementById('link'+n);
     247        o=document.getElementById(n);
    246248        oi=document.getElementById('L'+n);
    247249        if ( oi.innerHTML == attachmenton ) {
Note: See TracChangeset for help on using the changeset viewer.