我需要知道上传图像的原始大小。
我尝试过 get_option( 'thumbnail_size_w' )
和 get_option( 'thumbnail_size_h' )
并且我得到了 150x150 但找不到获取该图像原始大小的方法而不是缩略图。
我正在搜索类似 get_option( 'full_size_w' )
和 get_option( 'full_size_h' )
的内容,但它不起作用。
最佳答案
您可以检索尺寸为“full”的图像源。 “源”数组包含检索到的图像大小的尺寸。
$src = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' );
var_dump($src[1]); // image width
var_dump($src[2]); // image height
参见https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/了解更多信息。
关于wordpress - 获取特色图像原始尺寸的函数 - 全尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59529065/