Separate Large and Full image sizes. Props tellyworth. fixes #7151

git-svn-id: https://develop.svn.wordpress.org/trunk@8612 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-08-11 03:54:26 +00:00
parent 1c05d81e06
commit da4e0eca48
7 changed files with 88 additions and 30 deletions

View File

@@ -520,6 +520,41 @@ function media_upload_library() {
return wp_iframe( 'media_upload_library_form', $errors );
}
function image_size_input_fields($post, $checked='') {
// get a list of the actual pixel dimensions of each possible intermediate version of this image
$sizes = array();
$size_names = array('thumbnail' => 'Thumbnail', 'medium' => 'Medium', 'large' => 'Large', 'full' => 'Full size');
foreach ( $size_names as $size => $name) {
$downsize = image_downsize($post->ID, $size);
// is this size selectable?
$enabled = ( $downsize[3] || 'full' == $size );
$css_id = "image-size-{$size}-{$post->ID}";
// if $checked was not specified, default to the first available size that's bigger than a thumbnail
if ( !$checked && $enabled && 'thumbnail' != $size )
$checked = $size;
$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'" : '') ." />";
$html .= "<label for='{$css_id}'>" . __($name). "</label>";
// only show the dimensions if that choice is available
if ( $enabled )
$html .= " <label for='{$css_id}' class='help'>" . sprintf( __("(%d&nbsp;&times;&nbsp;%d)"), $downsize[1], $downsize[2] ). "</label>";
$html .= '</div>';
$out[] = $html;
}
return array(
'label' => __('Size'),
'input' => 'html',
'html' => join("\n", $out),
);
}
function image_attachment_fields_to_edit($form_fields, $post) {
if ( substr($post->post_mime_type, 0, 5) == 'image' ) {
$form_fields['post_title']['required'] = true;
@@ -529,8 +564,6 @@ function image_attachment_fields_to_edit($form_fields, $post) {
$form_fields['post_content']['label'] = __('Description');
$thumb = wp_get_attachment_thumb_url($post->ID);
$form_fields['align'] = array(
'label' => __('Alignment'),
'input' => 'html',
@@ -544,17 +577,7 @@ function image_attachment_fields_to_edit($form_fields, $post) {
<input type='radio' name='attachments[$post->ID][align]' id='image-align-right-$post->ID' value='right' />
<label for='image-align-right-$post->ID' class='align image-align-right-label'>" . __('Right') . "</label>\n",
);
$form_fields['image-size'] = array(
'label' => __('Size'),
'input' => 'html',
'html' => "
" . ( $thumb ? "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-thumb-$post->ID' value='thumbnail' />
<label for='image-size-thumb-$post->ID'>" . __('Thumbnail') . "</label>
" : '' ) . "<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-medium-$post->ID' value='medium' checked='checked' />
<label for='image-size-medium-$post->ID'>" . __('Medium') . "</label>
<input type='radio' name='attachments[$post->ID][image-size]' id='image-size-full-$post->ID' value='full' />
<label for='image-size-full-$post->ID'>" . __('Full size') . "</label>",
);
$form_fields['image-size'] = image_size_input_fields($post);
}
return $form_fields;
}