Install plugin: https://wordpress.org/plugins/force-regenerate-thumbnails/
and regenerate all thumbnails.
Or steps:
-
Create new dimension for images:
add_image_size ('thumb-cropped', 227, 133, true); // Set necessary sizes (true = cropped)
-
Get images with the sizes in you function.
get_the_post_thumbnail($post->ID);
fix to:
get_the_post_thumbnail($post->ID, 'thumb-cropped');
-
Install plugin: https://wordpress.org/plugins/force-regenerate-thumbnails/
-
Inter in admin area and regenerate all thumbnails
-
The end. Use all new images with fixed dimension