Changeset 3303 for trunk/wp-admin/inline-uploading.php
- Timestamp:
- 12/13/2005 07:19:56 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/inline-uploading.php
r3295 r3303 26 26 $images_width = 1; 27 27 28 function get_udims($width, $height) {29 if ( $height <= 96 && $width <= 128 )30 return array($width, $height);31 elseif ( $width / $height > 4 / 3 )32 return array(128, (int) ($height / $width * 128));33 else34 return array((int) ($width / $height * 96), 96);35 }36 37 28 switch($action) { 38 29 case 'delete': … … 56 47 57 48 $url = $file['url']; 49 $type = $file['type']; 58 50 $file = $file['file']; 59 51 $filename = basename($file); … … 65 57 'post_status' => 'attachment', 66 58 'post_parent' => $post, 67 'post_mime_type' => $ _FILES['image']['type'],59 'post_mime_type' => $type, 68 60 'guid' => $url 69 61 ); … … 80 72 $imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'"; 81 73 $imagedata['file'] = $file; 82 $imagedata['thumb'] = "thumb-$filename";83 74 84 75 add_post_meta($id, '_wp_attachment_metadata', $imagedata); … … 86 77 if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) { 87 78 if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 ) 88 $ error= wp_create_thumbnail($file, 128);79 $thumb = wp_create_thumbnail($file, 128); 89 80 elseif ( $imagedata['height'] > 96 ) 90 $error = wp_create_thumbnail($file, 96); 81 $thumb = wp_create_thumbnail($file, 96); 82 83 if ( @file_exists($thumb) ) { 84 $newdata = $imagedata; 85 $newdata['thumb'] = basename($thumb); 86 update_post_meta($id, '_wp_attachment_metadata', $newdata, $imagedata); 87 } else { 88 $error = $thumb; 89 } 91 90 } 92 91 } else { … … 163 162 $__using_thumbnail = __('Using Thumbnail'); 164 163 $__using_original = __('Using Original'); 164 $__using_title = __('Using Title'); 165 $__using_filename = __('Using Filename'); 166 $__using_icon = __('Using Icon'); 165 167 $__no_thumbnail = '<del>'.__('No Thumbnail').'</del>'; 166 168 $__send_to_editor = __('Send to editor'); … … 174 176 usingthumbnail = '$__using_thumbnail'; 175 177 usingoriginal = '$__using_original'; 178 usingtitle = '$__using_title'; 179 usingfilename = '$__using_filename'; 180 usingicon = '$__using_icon'; 176 181 var aa = new Array(); 177 182 var ab = new Array(); … … 180 185 var srca = new Array(); 181 186 var srcb = new Array(); 187 var title = new Array(); 188 var filename = new Array(); 189 var icon = new Array(); 182 190 "; 183 191 foreach ( $attachments as $key => $attachment ) { … … 194 202 $attachment = array_merge($attachment, $meta); 195 203 $send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a> 196 < a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&attachment={$ID}&all=$all&start=$start&post=$post\">$__delete</a>204 <!--<a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&attachment={$ID}&all=$all&start=$start&post=$post\">$__delete</a>--> 197 205 <a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a> 198 206 "; … … 235 243 "; 236 244 } else { 237 $script .= "aa[{$ID}] = '<a id=\"{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>'; 238 ab[{$ID}] = '<a id=\"{$ID}\" href=\"{$attachment['guid']}\" onclick=\"doPopup({$ID});return false;\" title=\"{$attachment['post_title']}\">{$attachment['post_title']}</a>'; 245 $title = $attachment['post_title']; 246 $filename = basename($attachment['guid']); 247 if ( $icon = get_attachment_icon($ID) ) 248 $toggle_icon = "<a id=\"I{$ID}\" onclick=\"toggleOtherIcon({$ID});return false;\" href=\"javascript:void()\">$__using_title</a>"; 249 $script .= "aa[{$ID}] = '<a id=\"{$ID}\" rel=\"attachment\" href=\"$href\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">{$attachment['post_title']}</a>'; 250 ab[{$ID}] = '<a id=\"{$ID}\" href=\"{$filename}\" onclick=\"doPopup({$ID});return false;\" title=\"{$title}\">{$attachment['post_title']}</a>'; 251 title[{$ID}] = '{$attachment['post_title']}'; 252 filename[{$ID}] = '{$filename}'; 253 icon[{$ID}] = '{$icon}'; 239 254 "; 240 255 $html .= "<div id='target{$ID}' class='attwrap left'> 241 <div id='div{$ID}' class='otherwrap ' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\">256 <div id='div{$ID}' class='otherwrap usingtext' onmousedown=\"selectLink({$ID})\" onclick=\"doPopup({$ID});return false;\"> 242 257 <a id=\"{$ID}\" href=\"{$attachment['guid']}\" onmousedown=\"selectLink({$ID});\" onclick=\"return false;\">{$attachment['post_title']}</a> 243 258 </div> … … 247 262 <div class='filetype'>".__('File Type:').' '.str_replace('/',"/\n",$attachment['post_mime_type'])."</div> 248 263 <a id=\"L{$ID}\" onclick=\"toggleOtherLink({$ID});return false;\" href=\"javascript:void()\">$__linked_to_file</a> 264 {$toggle_icon} 249 265 {$send_delete_cancel} 250 266 </div> … … 321 337 od=document.getElementById('div'+n); 322 338 ol=document.getElementById('L'+n); 339 oi=document.getElementById(n); 340 ih=oi.innerHTML; 323 341 if ( ol.innerHTML == linkedtofile ) { 324 342 od.innerHTML = aa[n]; … … 328 346 ol.innerHTML = linkedtofile; 329 347 } 348 oi=document.getElementById(n); 349 oi.innerHTML = ih; 330 350 } 331 351 function toggleImage(n) { … … 339 359 oi.innerHTML = usingthumbnail; 340 360 } 361 } 362 function toggleOtherIcon(n) { 363 od = document.getElementById('div'+n); 364 o = document.getElementById(n); 365 oi = document.getElementById('I'+n); 366 if ( oi.innerHTML == usingtitle ) { 367 o.innerHTML = filename[n]; 368 oi.innerHTML = usingfilename; 369 } else if ( oi.innerHTML == usingfilename ) { 370 o.innerHTML = icon[n]; 371 oi.innerHTML = usingicon; 372 } else { 373 o.innerHTML = title[n]; 374 oi.innerHTML = usingtitle; 375 } 376 if ( oi.innerHTML == usingicon ) 377 od.className = 'otherwrap usingicon'; 378 else 379 od.classname = 'otherwrap usingtext'; 341 380 } 342 381 … … 402 441 .otherwrap { 403 442 margin-right: 5px; 404 height: 90px;405 443 overflow: hidden; 406 444 background-color: #f9fcfe; 407 445 float: left; 408 padding: 3px;409 446 } 410 447 .otherwrap a { 411 448 display: block; 412 width: 122px;413 449 } 414 450 .otherwrap a, .otherwrap a:hover, .otherwrap a:active, .otherwrap a:visited { 415 451 color: blue; 452 } 453 .usingicon { 454 padding: 0px; 455 height: 96px; 456 text-align: center; 457 } 458 .usingicon a { 459 width: 128px; 460 } 461 .usingtext { 462 padding: 3px; 463 height: 90px; 464 text-align: left; 465 } 466 .usingtext a { 467 width: 122px; 416 468 } 417 469 .filetype {
Note: See TracChangeset
for help on using the changeset viewer.