Tag Archives: wordpress

Post really large images in WordPress

Note: this “fixit” may only apply to personally hosted WordPress installations where you are free to edit the source.

You may find that you have an image you’d like to embed in a WordPress post, but uploading the image results in either “HTTP Error” (if using the flash uploader) or some string of gobbledygook with a reference to some WordPress PHP file.

I was trying to upload larger versions of the images I use in my blog header for anyone who wanted to see them. The largest of the images had dimensions of 18618×3776. (Yes, that’s in pixels.) The problem, it turns out, had to do with dimensions or image size — more specifically, WordPress memory limits.

When you upload an image to your WordPress site — as of version 3.3.1 — WordPress will automatically attempt to generate common thumbnail sizes that you can insert into the post. While trying to upload this image, I found that WordPress was using > 400Mb of RAM during the resize operation. If you do the math on the image dimensions above, that’s a ~70 megapixel image it’s trying to manipulate.

By editing the file /wp-settings.php, I was able to get rid of the errors and the image was resized properly.

Look for the line: wp_initial_constants();

Immediately above this line, insert the following, save the file, and try your upload again.

define('WP_MEMORY_LIMIT', '256M');
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

Naturally you should massage those limits to reflect your specific installation, but adding these should get rid of the error(s) and allow WP to generate thumbnails for embedding.