使用wordpress post_thumbnail确定图像方向

wmf*_*ox3 1 wordpress

有没有办法在Wordpress中使用post_thumbnail功能时确定图像的方向?我创建了两种不同的尺寸,我需要使用合适的尺寸,即

the_post_thumbnail( 'article-pic-horizontal' );
Run Code Online (Sandbox Code Playgroud)

要么

the_post_thumbnail( 'article-pic-vertical' ); 
Run Code Online (Sandbox Code Playgroud)

wmf*_*ox3 11

打开一个更好的建议,但这是最终为我工作的:

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