How to make thumbnails in WordPress are the same size?

You need to make the thumbnails the same size (maintaining the aspect ratio of pictures, you can cut the picture)

code


foreach($posts as $post) { ?>
'img-responsive center-block padbot10' );
if ( has_post_thumbnail() ) { the_post_thumbnail('full', $attr); } // picture ?>







foreach($posts as $post) { ?>
'img-responsive center-block padbot10' );
if ( has_post_thumbnail() ) { the_post_thumbnail('full', $attr); } // picture ?>







foreach($posts as $post) { ?>
'img-responsive center-block padbot10' );
if ( has_post_thumbnail() ) { the_post_thumbnail('full', $attr); } // picture ?>






June 10th 19 at 16:10
1 answer
June 10th 19 at 16:12
Solution
Hello!
Please note that you have to the_post_thumbnail('full', $attr); provided full (full size images). You can set a different value for example, thumbnail, medium, large, or specify the desired size. If you need to set a specific image size, then you can also create a new size for the thumbnail.
In file functions.php add:
add_image_size( $name, $width, $height, $crop );
For example,
add_image_size(my_thumbnail, 800, 600, true );
name, width, height, boolean crop.

Don't forget after you create the new size you want to generate thumbnails plugin regenerate thumbnails

Accordingly, instead of the name the_post_thumbnail('full', $attr); specify the full name of your thumbnails
the change is expected to reach the site, right? on the main you only need to change the size of images without affecting the rest of the content - Alici commented on June 10th 19 at 16:15
now the thumbnails look like this
5a2ea67ae6848719755380.png

they need to have been exactly in one line. to distort the proportion you can not trim can - Alici commented on June 10th 19 at 16:18
Again, nothing has changed. You just need to find the code that displays the desired unit. Find the part of code where you specify the thumbnail size. And then modify the above method.

If you for example create a new image size and then enter the name of the thumbnail in the output unit Useful articles, the changes apply only to this block - rosario.Marv commented on June 10th 19 at 16:21
and the plugin regenerate thumbnails will not change the other thumbnails? - Alici commented on June 10th 19 at 16:24
The regenerate thumbnail plugin will re-generate all miniatry (in fact you will not see a difference), and create thumbnails of the desired size.

There is certainly another way to create thumbnails... for example, using wp-cli, but you need to study to connect to the site via ssh, install wp-cli and so on. etc. - rosario.Marv commented on June 10th 19 at 16:27
thank you! - Alici commented on June 10th 19 at 16:30

Find more questions by tags WordPress