has_image_size

函数
has_image_size ( $name )
参数
  • (string) $name The image size to check.
    Required:
返回值
  • (bool) True if the image size exists, false if not.
定义位置
相关方法
add_image_sizeimage_resizeimage_downsizeremove_image_sizewp_getimagesize
引入
3.9.0
弃用
-

has_image_size – 这是一个WordPress的函数,用来检查一个特定的图像尺寸是否已经被注册。图像尺寸是预定义的尺寸,用于在不同的情况下显示图像,如缩略图或特色图像。has_image_size函数接受一个参数,即图像尺寸的名称,如果该尺寸已经被注册,则返回true,如果没有,则返回false。

检查图像尺寸是否存在。

function has_image_size( $name ) {
	$sizes = wp_get_additional_image_sizes();
	return isset( $sizes[ $name ] );
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 20:33:00

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: