kmod's blog

10Aug/130

Improved blog speed by serving smaller images

Unbeknownst to me, I've been serving everyone full-sized images from my blog.  I didn't really notice this because I visit my blog often enough that my browser caches them and they seem to load instantly, but once I moved to a new computer I noticed how slow everything was.

The issue was that my server wasn't generating thumbnails, so I only had the option of inserting the full-size images; since I'm new to wordpress, I assumed that this was just how it worked.  It turns out that I was lacking the "php-gd" module, which meant that wordpress wasn't able to generate the thumbnails, and it didn't provide me the option to embed them instead of the full image.  I found this out from this answer.  The steps to fix it were pretty simple; for Ubuntu:

sudo apt-get install php5-gd
sudo apache2ctl restart

The next issue is that all my previous posts still have full-sized images in them.  Generating thumbnails for all of them is pretty standard; I used this plugin and it took just a few seconds.  One weird thing about installing the plugin was that I had the ownership on my /var/www folder set to root:root (was careless during the server upgrade I guess), and instead of giving me a useful error message, wordpress asked me for FTP credentials!  I suppose this might normally be the right thing to do, since it's far more standard for people to run wordpress in a shared environment where there's ftp but no other filesystem access, but it was confusing that it wasn't even noted.

Anyway, I got the plugin installed and generated all my thumbnails.  I spent 10 or so minutes googling around trying to figure out how to replace the images, and while I found any number of references on how to change existing thumbnail sizes, it doesn't seem possible to batch-replace images with a different size class.  I thought about going directly to the MySQL database and changing the embedded image URLs, but the name of the resized image is based on the resulting dimensions, which makes some sense but unfortunately makes it hard to batch-replace all images with the medium versions.  At this point I decided to give up and replace all the images by hand, since I've spent as much time already trying to figure out how not to do that as it would take to just bite the bullet and do it.

While I work on that, here's a teaser image of an upcoming post -- and correctly sized, I should add :)
2013-08-09 19.35.38

 

Filed under: hosting Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.