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 {
...
}
精彩评论