Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用wordpress post_缩略图确定图像方向_Wordpress - Fatal编程技术网

使用wordpress post_缩略图确定图像方向

使用wordpress post_缩略图确定图像方向,wordpress,Wordpress,在Wordpress中使用post_缩略图功能时,是否有方法确定图像的方向?我已经创建了两种不同的尺寸,我需要使用合适的尺寸,即 the_post_thumbnail( 'article-pic-horizontal' ); 或 接受更好的建议,但以下是最终对我有效的建议: $post_thumbnail_id = get_post_thumbnail_id( $post_id ); $imgmeta = wp_get_attachment_metadata( $post_thumbnail_

在Wordpress中使用post_缩略图功能时,是否有方法确定图像的方向?我已经创建了两种不同的尺寸,我需要使用合适的尺寸,即

the_post_thumbnail( 'article-pic-horizontal' );


接受更好的建议,但以下是最终对我有效的建议:

$post_thumbnail_id = get_post_thumbnail_id( $post_id );
$imgmeta = wp_get_attachment_metadata( $post_thumbnail_id );
if ($imgmeta['width'] > $imgmeta['height']) {
...
} else {
...
}
$post_thumbnail_id = get_post_thumbnail_id( $post_id );
$imgmeta = wp_get_attachment_metadata( $post_thumbnail_id );
if ($imgmeta['width'] > $imgmeta['height']) {
...
} else {
...
}