Does anybody know how to get square wordpress thumbnails?
If I use this the images aren't square
<?php the_post_thumbnail( array(205,205) ); ?>
But if I do this, they are square
<?php the_post_thumbnail( array(135,135) ); ?>
I need to create a thumbnail gallery with let s say 300 x 300 square images.
You have to create your own picture size first. This is done with the add_image_size() function.
You can do it like this:
This will add the support for thumbnails to your theme if it hasn't it already. It will create a new image size with cropped 300x300 pixels. The second function gives it a nicer description and makes sure it will show up in the media insert dialogs.
Then you can use it like this.
You can add these lines in the
functions.php
of your theme. If you want to make sure that these lines aren't overwritten when the theme gets updated I strongly suggest to create a child theme, you can read here how to do that.This will not affect existing images. You can recreate the missing thumbnails with this code:
This only has to be run once.