Due to updates, over time, that have been made to the site and the age of this article, this post may not display correctly. In particular images may be missing or product reviews display incorrectly.

If this is the case and you'd particularly like me to fix it, then please reach out to me on Twitter.

I mentioned in a post yesterday that I also use PHP to generate image thumbnails. The idea is that any new photos I simply upload to the BMTG site, with a Picasa caption attached, and the site should do the rest.

Thumbnails are generated on-the-fly but only once as, once created, they are saved and re-used.

$thumb_filename should contain the filename of the thumbnail and $full_filename is the filename of the original image (that the thumbnail is taken from). In the case of this example I’m creating thumbnails that have a height of 100 pixels and maintain their ratio, hence the width is variable.

The above can be made a lot more compact, but I’ve expanded it out to make it easier to follow.

By the time the code has finished, if the thumbnail didn’t already exist, it now does. Make sure the folder that the thumbnails are stored in has the appropriate permissions though!