In WordPress, images are automatically re-saved in different sizes like creating a thumbnail. But what happens if you want to use your own image? or want a different size?
WordPress default image sizes
The standard WordPress image sizes are:
- Thumbnail (no more than 150px wide)
- Medium (no more than 300px)
These basically are crops and the size (width) is based on the aspect ratio. So you can't always guarantee that your thumbnail will be exactly 150px x 150px.
How to get your image thumbnail
In my plugins, I use the standard WordPress image sizes like this:
get_the_post_thumbnail($id, 'thumbnail', array('class' => 'dsimage'))
get_the_post_thumbnail($id, array(200,200), array('class' => 'dsimage'))
Note: each image will also get a custom class added called dsimage - this means you can style it.Tags:
Read more from my blog for an introduction and quick tips on developing in Hugo or UCTD.