Is there a way to only display <?php the_post_thumbnail( $size, $attr ); ?>
if it is larger/smaller than specified dimensions?
2 comments
Comments are closed.
Is there a way to only display <?php the_post_thumbnail( $size, $attr ); ?>
if it is larger/smaller than specified dimensions?
Comments are closed.
You may be able to make this work with a filter on
post_thumbnail_html
.I am not sure what you mean by “if it is larger/smaller…”. I don’t know if need both conditions at once, or one or the other, or if you need to change the restrictions dynamically. The code above should give you a working model though.
Reference
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/post-thumbnail-template.php#L85
This should work
Define
width
andheight
, and thesize
andattr
that you want.