I launched the blog on 5 May (even though the first battle was said to be on 4 May). On 6 May I had to debug the way images were uploaded and displayed.
I wanted to upload raw images from the camera at full size (so they’ll be archived on the server if I want them later) and then have WordPress automatically create images of a size appropriate for the posts. I thought the CMS was already set up to do this. But no.
It wasn’t working. Some of the images wouldn’t upload: WP just gave me a broken image icon. Others would upload but not resize to the three built-in sizes.
I determined that there must be a memory limit problem. My server’s PHP just didn’t want to resize raw images from the camera that were thousands of pixels across and 5MB each. WP says the upload size limit is 7MB, but apparently problems happen even with files that are smaller than that.
I toyed with the idea of trying to increase my PHP memory limit, but in the end just gave in and resized the raw files down to 2000 pixels across. Then I started seeing three sizes generated automatically.
The problem wasn’t solved, though. I thought I was picking the auto-generated size to display in the post, the image that stretches across the full width of the post content div. But WP was displaying an even bigger image and resizing it in HTML to the width of the post. I was not going to stand for that. Resizing in HTML from 1024 to 604 is just stupid.
Eventually I realized that the auto-generated images I thought I was picking to display in the posts were a size that the theme uses for “featured images”. Those images have the tops and bottoms of my images cropped out. I was seeing the width dimension of those images and assuming the height was what I wanted. WP was assuming I wanted my large not-cropped image resized to the post width via HTML because nowhere was I actually telling WP that I wanted my upload resaved at that size.
The solution was to register a new custom image size, and tell WP that I wanted the size to be selectable in the image menus. So, two code snippets later, everything was working just as I wanted it to.
You think WordPress is a turn-key system? Think again…
Computers don’t do what you want. They do what you tell them. So tell them what you want very carefully.