Reputation: 602
I'm working on a new design for my current Wordpress theme. On the old version our featured images were 125x80, and on the new version they are 650x300. Rather than go back through tons of posts and put the new featured image on, is there a way I can write an if statement so that if it sees the width on the featured image is 125px to not execute anything, but if it's 650px to go ahead and do the_post_thumbnail();?
Upvotes: 0
Views: 115
Reputation: 46
you can use do some think like this
<?php
$id = get_post_thumbnail_id();
$image_attributes = wp_get_attachment_image_src( $id ); // returns an array
if ($image_attributes[1] > 125) {
// $image_attributes[1] - stands for image width
//do your code...
}
?>
Hope it helps you.
Upvotes: 3