Changeset 8653 for trunk/wp-admin/includes/media.php
- Timestamp:
- 08/15/2008 03:40:35 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r8612 r8653 521 521 } 522 522 523 // produce HTML for the image alignment radio buttons with the specified one checked 524 function image_align_input_fields($post, $checked='') { 525 526 $alignments = array('none' => 'None', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right'); 527 if ( !array_key_exists($checked, $alignments) ) 528 $checked = 'none'; 529 530 $out = array(); 531 foreach ($alignments as $name => $label) { 532 533 $out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='none'". 534 ( $checked == $name ? " checked='checked'" : "" ) . 535 " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>" . __($label) . "</label>"; 536 } 537 return join("\n", $out); 538 } 539 540 // produce HTML for the size radio buttons with the specified one checked 523 541 function image_size_input_fields($post, $checked='') { 524 542 525 543 // get a list of the actual pixel dimensions of each possible intermediate version of this image 526 $sizes = array();527 544 $size_names = array('thumbnail' => 'Thumbnail', 'medium' => 'Medium', 'large' => 'Large', 'full' => 'Full size'); 528 545 … … 556 573 } 557 574 575 // produce HTML for the Link URL buttons with the default link type as specified 576 function image_link_input_fields($post, $url_type='') { 577 578 $file = wp_get_attachment_url($post->ID); 579 $link = get_attachment_link($post->ID); 580 581 $url = ''; 582 if ( $url_type == 'file' ) 583 $url = $file; 584 elseif ( $url_type == 'post' ) 585 $url = $link; 586 587 return "<input type='text' name='attachments[$post->ID][url]' value='" . attribute_escape($url) . "' /><br /> 588 <button type='button' class='button url-$post->ID' value=''>" . __('None') . "</button> 589 <button type='button' class='button url-$post->ID' value='" . attribute_escape($file) . "'>" . __('File URL') . "</button> 590 <button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post URL') . "</button> 591 <script type='text/javascript'> 592 jQuery('button.url-$post->ID').bind('click', function(){jQuery(this).siblings('input').val(this.value);}); 593 </script>\n"; 594 } 595 558 596 function image_attachment_fields_to_edit($form_fields, $post) { 559 597 if ( substr($post->post_mime_type, 0, 5) == 'image' ) { … … 568 606 'label' => __('Alignment'), 569 607 'input' => 'html', 570 'html' => " 571 <input type='radio' name='attachments[$post->ID][align]' id='image-align-none-$post->ID' value='none' checked='checked' /> 572 <label for='image-align-none-$post->ID' class='align image-align-none-label'>" . __('None') . "</label> 573 <input type='radio' name='attachments[$post->ID][align]' id='image-align-left-$post->ID' value='left' /> 574 <label for='image-align-left-$post->ID' class='align image-align-left-label'>" . __('Left') . "</label> 575 <input type='radio' name='attachments[$post->ID][align]' id='image-align-center-$post->ID' value='center' /> 576 <label for='image-align-center-$post->ID' class='align image-align-center-label'>" . __('Center') . "</label> 577 <input type='radio' name='attachments[$post->ID][align]' id='image-align-right-$post->ID' value='right' /> 578 <label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n", 608 'html' => image_align_input_fields($post, get_option('image_default_align')), 579 609 ); 580 $form_fields['image-size'] = image_size_input_fields($post); 610 611 $form_fields['image-size'] = image_size_input_fields($post, get_option('image_default_size')); 581 612 } 582 613 return $form_fields; … … 655 686 'label' => __('Link URL'), 656 687 'input' => 'html', 657 'html' => " 658 <input type='text' name='attachments[$post->ID][url]' value='" . attribute_escape($file) . "' /><br /> 659 <button type='button' class='button url-$post->ID' value=''>" . __('None') . "</button> 660 <button type='button' class='button url-$post->ID' value='" . attribute_escape($file) . "'>" . __('File URL') . "</button> 661 <button type='button' class='button url-$post->ID' value='" . attribute_escape($link) . "'>" . __('Post URL') . "</button> 662 <script type='text/javascript'> 663 jQuery('button.url-$post->ID').bind('click', function(){jQuery(this).siblings('input').val(this.value);}); 664 </script>\n", 688 'html' => image_link_input_fields($post, get_option('image_default_link_type')), 665 689 'helps' => __('Enter a link URL or click above for presets.'), 666 690 ), … … 1313 1337 } 1314 1338 1339 $default_align = get_option('image_default_align'); 1340 if ( empty($default_align) ) 1341 $default_align = 'none'; 1342 1315 1343 return ' 1316 1344 <table class="describe"><tbody> … … 1342 1370 <th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th> 1343 1371 <td class="field"> 1344 <input name="align" id="align-none" value="alignnone" onclick="addExtImage.align=this.value" type="radio" checked="checked"/>1372 <input name="align" id="align-none" value="alignnone" onclick="addExtImage.align=this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' /> 1345 1373 <label for="align-none" class="align image-align-none-label">' . __('None') . '</label> 1346 <input name="align" id="align-left" value="alignleft" onclick="addExtImage.align=this.value" type="radio" />1374 <input name="align" id="align-left" value="alignleft" onclick="addExtImage.align=this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' /> 1347 1375 <label for="align-left" class="align image-align-left-label">' . __('Left') . '</label> 1348 <input name="align" id="align-center" value="aligncenter" onclick="addExtImage.align=this.value" type="radio" />1376 <input name="align" id="align-center" value="aligncenter" onclick="addExtImage.align=this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' /> 1349 1377 <label for="align-center" class="align image-align-center-label">' . __('Center') . '</label> 1350 <input name="align" id="align-right" value="alignright" onclick="addExtImage.align=this.value" type="radio" />1378 <input name="align" id="align-right" value="alignright" onclick="addExtImage.align=this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' /> 1351 1379 <label for="align-right" class="align image-align-right-label">' . __('Right') . '</label> 1352 1380 </td>
Note: See TracChangeset
for help on using the changeset viewer.