开发者

determining image orientation using wordpress post_thumbnail

Is there a way to determine the orientation of the image when using the post_thumbnail functionality in Wordpress? I've got two different sizes created and I need to use the appropriate one, i.e.

the_post_thumbnail( 'article-pic-horizontal' );
开发者_开发百科

or

the_post_thumbnail( 'article-pic-vertical' ); 


Open to a better suggestion, but here's what ended up working for me:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜