image_size_input_fields
函数
image_size_input_fields ( $post, $check = '' )
- 参数
-
-
(WP_Post)
$post- Required: 是
-
(bool|string)
$check- Required: 否
- Default: (empty)
-
(WP_Post)
- 返回值
-
- (array)
- 定义位置
-
-
wp-admin/includes/media.php
, line 1179
-
wp-admin/includes/media.php
- 引入
- 2.7.0
- 弃用
- –
Retrieves HTML for the size radio buttons with the specified one checked.
function image_size_input_fields( $post, $check = '' ) {
/**
* Filters the names and labels of the default image sizes.
*
* @since 3.3.0
*
* @param string[] $size_names Array of image size labels keyed by their name. Default values
* include 'Thumbnail', 'Medium', 'Large', and 'Full Size'.
*/
$size_names = apply_filters(
'image_size_names_choose',
array(
'thumbnail' => __( 'Thumbnail' ),
'medium' => __( 'Medium' ),
'large' => __( 'Large' ),
'full' => __( 'Full Size' ),
)
);
if ( empty( $check ) ) {
$check = get_user_setting( 'imgsize', 'medium' );
}
$output = array();
foreach ( $size_names as $size => $label ) {
$downsize = image_downsize( $post->ID, $size );
$checked = '';
// Is this size selectable?
$enabled = ( $downsize[3] || 'full' === $size );
$css_id = "image-size-{$size}-{$post->ID}";
// If this size is the default but that's not available, don't select it.
if ( $size == $check ) {
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'";
}
$html = "
ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
$html .= "";
// Only show the dimensions if that choice is available.
if ( $enabled ) {
$html .= " ';
}
$html .= '';
$output[] = $html;
}
return array(
'label' => __( 'Size' ),
'input' => 'html',
'html' => implode( "n", $output ),
);
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


