Worries with WordPress: Image Resampling [en]

One of the main reasons I started this blog in the first place was to share photos. Mainly stuff related to travels, nature, snowboarding, architecture and street-art. You may have noticed that such stuff has been extremly scarce so far.

Apart from my own lazyness, this is due to technical difficulties related to the way WordPress handles photos. I wanted to upload my photos in fairly good quality (e.g. JPEG, 3000×4000 pixels, 3MB) and let WordPress handle the generation of resampled  thumbnail-images to be included in the posts.

Unfortunately WordPress just failed to resample the images! The radio-buttons for image size in the add-an-image dialog were simply blanked out. There was no indication why that was the case ‒ no error messages whatsoever.

Searching the web quickly revealed that the problem might be related to missing graphics libraries or the image size. However, information on the latter issue was fragmented. Some claimed that there are limits built into wordpress ‒ either limits on pixel-size or file-size. Others claimed that such problems are solely related to the memory settings of PHP, the web-server, or the OS. Moreover, the roots of image-resizing issues seem to vary a lot accross different versions of wordpress. And so do the approaches to solve these issues.

Here’s what worked for me in WordPress 3.0.3:

In my case, it was just the PHP memory-limit in the end. Although I already have a quite generous memory_limit setting in my php.ini config-file, it seemed that it was not sufficient. I did not want to increase that limit globaly, in order to avoid PHP scripts running havoc. Luckily I found a way to increase the memory-limit just for WordPress image resampling.

You have to edit the following file in your WordPress install directory:


There, in function wp_load_image there’s a line like:

@ini_set('memory_limit', '256M');

Just change the 256M to whatever amount of memory is necessary to scale your images. I’m using 512M now, which seems to work for all the images I uploaded so far.

One gotcha I should mention:

WordPress does not do image-resampling every time you want to insert an image-thumbnail into a post.  Instead, it does image-resampling right after the upload of an image. If that fails, the thumbnails are simply not available. Also there does not seem to be a built-in way to re-trigger image resampling. Luckily, there’s the Regenerate Thumbnails WordPress plugin, which solves exactly that problem. You can easily trigger it from the WordPress Admin to resample single images or the whole media librariy.

Another plugin I find really useful when working with images is Add From Server. As the name suggests, it helps you add images from the Server’s filesystem to the WordPress media library. That way you can use your favorite file transfer tool to bulk upload images, and quickly include them into WordPress.

More Worries with WordPress: UAM

While my problems with image resampling are solved now, I’m still not set to publish images in my blog. Appearently the UAM plugin I’m using is having trouble handle the resampled image. UAM adds access control to WordPress, and allows to limit certain posts and media to registerd users. However it does not seem to work well with resampled images. I’m off to the code to look into it…

Leave a comment