I am setting featured images to posts, and displaying a default image if one isn’t set. My code is here…
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail( 'full', array( 'class' => 'img-responsive' ) );
} else { ?>
<img src="default-image.jpg" class="img-responsive" />
<?php } ?>
Problem is simple. All of the images are different heights. I want them all to be uniform height so my bootstrap grid lines up evenly.
Any thoughts? Lots of examples online but none work with featured image AND default image.
Please Paste below code in your functions.php file
Now when ever you upload any image in wordpress post it automatically resize into 510*520 (but bee care full image size must be bigger than what ratio you want)
How to call please check Below
In your code, add the “unim” class like so:
To achieve uniform images on site, you can use the open source library bootstrap-spacer via NPM
or you can visit the github page:
Here’s an example of how this works using the “unim” class (you’d require jQuery for this):