/ dev

Adding thumbnails

I sent a link to this blog to my mate and commented that github pages were a bit slow to serve it. He replied ""shouldn't be, github pages are usually pretty snappy", he then went on to say "however, you are linking to your full sized images on the index page". Ah, oops! Good point that... He sent me a link to a script that he'd used for generating thumbnails from existing images so I decided that I'd just hack on that and change it to my needs. Before doing that, I decided to have a bit of a Google for pelican thumbnails - it didn't seem to me that I'd be the first person to be doing this. I discovered pelican thumbnailer which looked ideal to me. Armed with the thumbnailer I did some testing. Yup, it generated thumbnails from my images, great! The next step was linking to these images from my posts, I decided the simple way to do this was to add a new metadata field to my posts called "Thumbnail: " just containing the path to where the thumbnail should be once generated. Well, I wasn't going to do this manually was I? I wrote a little script to find the first image in my markdown (if any) and then take the path and add a new line as detailed above. Bit of testing and all looked good. As can be seen in my photo a day posts the links work and the index page is loading much faster, at time of testing: 7.7mb down to 232kb!

Adding thumbnails
Share this