Cropped featured image in WordPress

It may be a featured image on the front end, but is post_thumbnail when it comes to back end and actually implementing it into the site. Adding cropped featured image in WordPress is quite easy though. First you need to add featured image support to your website (make sure to add it to after_setup_theme hook) – needless to say you would add it to functions.php:

Let’s assume that you already chosen featured image dimensions (on either posts or pages). Now you want to crop whatever user uploaded to fit your container. Therefore you may want to add your custom size:

True means that you enabled hard cropping function. You can also fine-tune the cropping function if using an array (start cropping from left, center, or right, for example). You will find about its detailed use within code reference (check the link below).

So the full code that goes into functions.php would be something like:

And this is how you call it (must be within the loop) on your page or post template:

References: