In Settings > Media, you are able to set only the height or width of the Thumbnail images and WordPress will resize them proportionally (i.e.: if you have a fixed height, then the widths will vary depending on your uploaded image dimension, and vice versa).
Inside the loop, you can get a thumbnail’s width, height and URL using this code:
<pre>$imgdata = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' ); $imgurl = $imgdata[0]; // the url of the thumbnail picture $imgwidth = $imgdata[1]; // thumbnail's width $imgheight = $imgdata[2]; // thumbnail's height</pre>
For the second parameter of the wp_get_attachment_image_src
function you can also use ‘medium’, ‘large’ and ‘full’. They correspond to the dimension for the other sizes in Settings > Media.
Revisions
There are no revisions for this post.
No comments yet.