In image_size_input_fields()
:
* Declare `$out` as an empty array - this is not a strict PHP requirement, but is a good practice before loops * Most of this function was tabbed twice, instead of once See #30799. git-svn-id: https://develop.svn.wordpress.org/trunk@30981 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a75c7977b9
commit
91dcf8796b
@ -949,7 +949,6 @@ function image_align_input_fields( $post, $checked = '' ) {
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function image_size_input_fields( $post, $check = '' ) {
|
function image_size_input_fields( $post, $check = '' ) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the names and labels of the default image sizes.
|
* Filter the names and labels of the default image sizes.
|
||||||
*
|
*
|
||||||
@ -965,50 +964,53 @@ function image_size_input_fields( $post, $check = '' ) {
|
|||||||
'full' => __( 'Full Size' )
|
'full' => __( 'Full Size' )
|
||||||
) );
|
) );
|
||||||
|
|
||||||
if ( empty($check) )
|
if ( empty( $check ) ) {
|
||||||
$check = get_user_setting('imgsize', 'medium');
|
$check = get_user_setting('imgsize', 'medium');
|
||||||
|
}
|
||||||
|
$out = array();
|
||||||
|
|
||||||
foreach ( $size_names as $size => $label ) {
|
foreach ( $size_names as $size => $label ) {
|
||||||
$downsize = image_downsize($post->ID, $size);
|
$downsize = image_downsize( $post->ID, $size );
|
||||||
$checked = '';
|
$checked = '';
|
||||||
|
|
||||||
// Is this size selectable?
|
// Is this size selectable?
|
||||||
$enabled = ( $downsize[3] || 'full' == $size );
|
$enabled = ( $downsize[3] || 'full' == $size );
|
||||||
$css_id = "image-size-{$size}-{$post->ID}";
|
$css_id = "image-size-{$size}-{$post->ID}";
|
||||||
|
|
||||||
// If this size is the default but that's not available, don't select it.
|
// If this size is the default but that's not available, don't select it.
|
||||||
if ( $size == $check ) {
|
if ( $size == $check ) {
|
||||||
if ( $enabled )
|
if ( $enabled ) {
|
||||||
$checked = " checked='checked'";
|
|
||||||
else
|
|
||||||
$check = '';
|
|
||||||
} elseif ( !$check && $enabled && 'thumbnail' != $size ) {
|
|
||||||
/*
|
|
||||||
* If $check is not enabled, default to the first available size
|
|
||||||
* that's bigger than a thumbnail.
|
|
||||||
*/
|
|
||||||
$check = $size;
|
|
||||||
$checked = " checked='checked'";
|
$checked = " checked='checked'";
|
||||||
|
} else {
|
||||||
|
$check = '';
|
||||||
}
|
}
|
||||||
|
} elseif ( ! $check && $enabled && 'thumbnail' != $size ) {
|
||||||
$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
|
/*
|
||||||
|
* If $check is not enabled, default to the first available size
|
||||||
$html .= "<label for='{$css_id}'>$label</label>";
|
* that's bigger than a thumbnail.
|
||||||
|
*/
|
||||||
// Only show the dimensions if that choice is available.
|
$check = $size;
|
||||||
if ( $enabled )
|
$checked = " checked='checked'";
|
||||||
$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d × %d)", $downsize[1], $downsize[2] ). "</label>";
|
|
||||||
|
|
||||||
$html .= '</div>';
|
|
||||||
|
|
||||||
$out[] = $html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
|
||||||
'label' => __('Size'),
|
|
||||||
'input' => 'html',
|
$html .= "<label for='{$css_id}'>$label</label>";
|
||||||
'html' => join("\n", $out),
|
|
||||||
);
|
// Only show the dimensions if that choice is available.
|
||||||
|
if ( $enabled ) {
|
||||||
|
$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d × %d)", $downsize[1], $downsize[2] ). "</label>";
|
||||||
|
}
|
||||||
|
$html .= '</div>';
|
||||||
|
|
||||||
|
$out[] = $html;
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'label' => __( 'Size' ),
|
||||||
|
'input' => 'html',
|
||||||
|
'html' => join( "\n", $out ),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user