We start at the bottom of the code and I’ll work my way back up.

Here we set up a function that will add four new thumbnail sizes to our WordPress website.

The function add_image_size() is the one that’s doing the work.  Have a look at the linked codex for an explanation of the parameters and to see how you can configure the way the thumbnails are cropped.

17Three of these files (called thumbnails) are sized at 150×150, 300×300, 640×640 pixels respectively with the fourth being the original image you uploaded.

WordPress does this to help serve up images quickly, rather than using processor intensive scripts to dynamically resize a single image.

Yes it can lead to a lot of duplication and addition disk space but space is so cheap nowadays it’s hardly an issue at all.

Thumbnails will be created only up to the size of the original image as there’s no point having a 25×25 icon being blown up to 640×640.