wpseek.com
WordPress开发者和主题制作者的搜索引擎
file_is_displayable_image › WordPress Function
Since2.5.0
已弃用n/a
› file_is_displayable_image ( $path )
| 参数: |
|
| 返回: |
|
| 定义在: |
|
| 文档: |
Validates that file is suitable for displaying within a web page.
Related Functions: file_is_valid_image, display_space_usage, maybe_disable_link_manager, is_gd_image, media_upload_image
源码
function file_is_displayable_image( $path ) {
$displayable_image_types = array( IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG, IMAGETYPE_BMP, IMAGETYPE_ICO, IMAGETYPE_WEBP, IMAGETYPE_AVIF );
$info = wp_getimagesize( $path );
if ( empty( $info ) ) {
$result = false;
} elseif ( ! in_array( $info[2], $displayable_image_types, true ) ) {
$result = false;
} else {
$result = true;
}
/**
* Filters whether the current image is displayable in the browser.
*
* @since 2.5.0
*
* @param bool $result Whether the image can be displayed. Default true.
* @param string $path Path to the image.
*/
return apply_filters( 'file_is_displayable_image', $result, $path );
}