I noticed recently that when uploading files larger than 7mb to a Wordpress site that I developed, I get an HTTP Error. I've checked some of my PHP variables, and have verified that memory_limit is set to 256M and both post_max_size and upload_max_filesize are set to 128M. After reading this thread, I tried installing the Default to GD plugin that uses GD as the default WP_Image_Editor class.

After installing the plugin, I'm not having the issue anymore. That said, I'm curious if there's a way to fix this issue with the newer WP_Image_Editor class?

I've also noticed that when I get the HTTP error, I can look at the files attached to the post I added the file to and see that the file is actually there and was successfully uploaded. However, Wordpress seems to have issues displaying it in the Media browser.

I also noticed that if I upload multiple large images over 7mb, I will see the most recent image as the first item in the media library. If I delete that image, I'll see the next most recently uploaded image. For some reason Wordpress is only able to show the most recent image and the thumbnail seems to be broken. However if you navigate to the uploaded file's URI, you can see that the file uploaded successfully.

Does anyone have an idea what's going on with this and is this a known error in Wordpress that's being addressed? Thanks!

I sometimes get this exact same issue and set of symptoms.

It's caused by the image being too large for the memory available. Not the file size as that has compressed data, but the actual width x height x colourdepth.

You can see the full size image because it uploaded fine. You have trouble in the media browser because WP ran out of memory while scaling and cropping the image and so there is no version available for the media browser thumbnail.

I've always found that allocating much more memory to the process fixes it. Or use smaller images (dimensions, not file size).

WordPress will use the higher of WP_MAX_MEMORY_LIMIT and your PHP memory limit, so as long as your hosting allows the easiest thing to do is to set WP_MAX_MEMORY_LIMIT in your wp-config.php:

define( 'WP_MAX_MEMORY_LIMIT', '257M' ); // you choose how much

The default is 256M for image handling anyway, so if you have problems resizing images it'll need to be something higher than 256M.

As long as your host allows PHP to increase the memory using @ini_set then this will work.

  • As far as allocating more memory, would I need to allocate it on the server in my php settings or would this be a Wordpress setting? I am using the Server IP & Memory Usage Display plugin. It shows that I have a total of 256mb of memory but also says WP LIMIT: 40 MB is there a separate Wordpress Memory Limit I could change? – Hendeca Jun 22 at 20:43
  • it's a PHP thing not a WP thing – Tom J Nowell Jun 22 at 20:59
  • As @TomJNowell says, it's PHP, though I think fair to ask it on WPSE as it's a pretty general issue for WP now everyone's cameras can take such large images. Just increasing the allowed RAM, and possibly the execution time, in PHP should do the trick. Within WP it will try and raise that WP Limit within the PHP bounds for image processing and for admin side tasks. – Andy Macaulay-Brook Jun 22 at 21:02
  • @AndyMacaulay-Brook I've tried increasing the WP_MAX_MEMORY LIMIT to 512M by defining it in my wp-config and am still having the issue. I also tried setting WP_MEMORY_LIMIT to 128M which also didn't solve the problem. I realize using smaller image dimensions could solve the problem, but given that the client would like to be able to upload larger dimension images, I wanted to first see if there were other options. Do you have any other ideas as to what might solve this issue? – Hendeca Jun 25 at 16:17

You will need to change your memory limit within your php.ini file. You will want to add or update the following information:

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

In my personal experience, I wouldn't make it 256 MB, but I'd maybe make it 60 as opposed to 40 like you said above.

if you are running apache base webserver then you could use this code into your htaccess file

SetEnv MAGICK_THREAD_LIMIT 1

I have fixed my problem by using this code. You can try.

  • Pasting code into your web server configuration without an explanation of what it does is not such a good idea. You could maybe expand your answer with an explanation of what this setting does. – Andy Macaulay-Brook Jun 23 at 10:05
  • Thanks for suggestion. I will try to explain about this reply. – Ariful Islam Jun 24 at 7:36

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.