I am trying to set the width of a post thumbnail using
the_post_thumbnail().
The width of the image needs to be 210px but the height is not meant to be fixed as all the images will be different sizes. I have tried
the_post_thumbnail(array(210,0))
but this does not work. Any ideas?
Thanks
Open your themes functions.php file and add your image size:
Example:
Breakdown of the code:
'slider'
= The name of the new image size (use this when adding the new image size to your template file).525
= The image width339
= The image heighttrue
= The image will be cropped to the exact dimensions listed.Usage: Use a current template (index.php, single.php, etc.), or create your own. Place this inside the loop (usually just after
the_title();
) :Now when you add a page or post that uses the template you added the code above, use the featured image option to upload an image. It will output to the size you've created.
Note: This will only apply to newly uploaded images.
Did you try this : Thumbnail Custom Size
It is the best way to change Thumbnail Size.
Change
the_post_thumbnail(array(210,0))
tothe_post_thumbnail(array(210,9999))
Add this inside your functions.php
Use it inside your theme's template files
For default thumbnail add this inside your functions.php
Reference: Here.