Changeset 12188 for trunk/wp-admin/includes/media.php
- Timestamp:
- 11/16/2009 01:37:30 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r12162 r12188 781 781 function image_align_input_fields( $post, $checked = '' ) { 782 782 783 if ( empty($checked) ) 784 $checked = get_user_setting('align', 'none'); 785 783 786 $alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right')); 784 787 if ( !array_key_exists( (string) $checked, $alignments ) ) … … 786 789 787 790 $out = array(); 788 foreach ( $alignments as $name => $label) {791 foreach ( $alignments as $name => $label ) { 789 792 $name = esc_attr($name); 790 793 $out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'". 791 794 ( $checked == $name ? " checked='checked'" : "" ) . 792 " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'> " . $label . "</label>";795 " /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>"; 793 796 } 794 797 return join("\n", $out); … … 804 807 * @return unknown 805 808 */ 806 function image_size_input_fields( $post, $check ed= '' ) {809 function image_size_input_fields( $post, $check = '' ) { 807 810 808 811 // get a list of the actual pixel dimensions of each possible intermediate version of this image 809 812 $size_names = array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full size')); 810 813 811 foreach ( $size_names as $size => $name ) { 814 if ( empty($check) ) 815 $check = get_user_setting('imgsize', 'medium'); 816 817 foreach ( $size_names as $size => $label ) { 812 818 $downsize = image_downsize($post->ID, $size); 819 $checked = ''; 813 820 814 821 // is this size selectable? … … 816 823 $css_id = "image-size-{$size}-{$post->ID}"; 817 824 // if this size is the default but that's not available, don't select it 818 if ( $checked && !$enabled ) 819 $checked = ''; 820 // if $checked was not specified, default to the first available size that's bigger than a thumbnail 821 if ( !$checked && $enabled && 'thumbnail' != $size ) 822 $checked = $size; 823 824 $html = "<div class='image-size-item'><input type='radio' ".( $enabled ? '' : "disabled='disabled'")."name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'".( $checked == $size ? " checked='checked'" : '') ." />"; 825 826 $html .= "<label for='{$css_id}'>" . __($name). "</label>"; 825 if ( $size == $check ) { 826 if ( $enabled ) 827 $checked = " checked='checked'"; 828 else 829 $check = ''; 830 } elseif ( !$check && $enabled && 'thumbnail' != $size ) { 831 // if $check is not enabled, default to the first available size that's bigger than a thumbnail 832 $check = $size; 833 $checked = " checked='checked'"; 834 } 835 836 $html = "<div class='image-size-item'><input type='radio' " . ( $enabled ? '' : "disabled='disabled' " ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />"; 837 838 $html .= "<label for='{$css_id}'>$label</label>"; 827 839 // only show the dimensions if that choice is available 828 840 if ( $enabled ) … … 850 862 * @return unknown 851 863 */ 852 function image_link_input_fields($post, $url_type ='') {864 function image_link_input_fields($post, $url_type = '') { 853 865 854 866 $file = wp_get_attachment_url($post->ID); 855 867 $link = get_attachment_link($post->ID); 868 869 if ( empty($url_type) ) 870 $url_type = get_user_setting('urlbutton', 'post'); 856 871 857 872 $url = ''; … … 861 876 $url = $link; 862 877 863 return "<input type='text' class='urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br /> 864 <button type='button' class='button urlnone' title=''>" . __('None') . "</button> 865 <button type='button' class='button urlfile' title='" . esc_attr($file) . "'>" . __('File URL') . "</button> 866 <button type='button' class='button urlpost' title='" . esc_attr($link) . "'>" . __('Post URL') . "</button> 878 return " 879 <input type='text' class='urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br /> 880 <button type='button' class='button urlnone' title=''>" . __('None') . "</button> 881 <button type='button' class='button urlfile' title='" . esc_attr($file) . "'>" . __('File URL') . "</button> 882 <button type='button' class='button urlpost' title='" . esc_attr($link) . "'>" . __('Post URL') . "</button> 867 883 "; 868 884 } … … 897 913 ); 898 914 899 $form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size' ) );915 $form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') ); 900 916 901 917 } else {
Note: See TracChangeset
for help on using the changeset viewer.