3

I'm getting an HTTP Error message when uploading a big jpg file (about 30 - 40MB) and I can see 500 Internal Server Error response in the Chrome dev tools network tab returned by the async-upload.php.

The error appears after the file is uploaded. I can see the file in the wp-content/uploads directory, so the problem is not related to the uploading process.

I suppose that the problem is related to images resizing process that happens after the file is uploaded. I tried to rebuild thumbnails manually (using several regenerate thumbnails plugins) to prove that the problem is related to the resizing process. All of them failed to resize a large image.

Things I did before posting this question:

  • I've increased the memory limit to 256MB in the php.ini file (memory_limit = 256M)
  • set post_max_size = 256M
  • Set up a fresh WP instance. No plugins, default theme.
  • Tested on a different machine (on VPS, same PHP settings)
  • I've turned off mod_security settings:

    <IfModule mod_security.c>
        SecFilterEngine Off
        SecFilterScanPOST Off
    </IfModule>
    
  • I've also tried to change the default image library:

    add_filter('wp_image_editors', function () {
        return ['WP_Image_Editor_GD', 'WP_Image_Editor_Imagick'];
    });
    

UPDATE:

I've just realised that the filter I've applied didn't do anything. I have check the WP source code, and found that default value for this filter is: ['WP_Image_Editor_Imagick', 'WP_Image_Editor_GD']. I've changed the order, but I didn't have Image Magic library installed, so WordPress has been using GD library anyway.

So I have installed the Image Magic PHP extension to give it try. I've also removed the filter because it's default value works for me.

Replacing GD library with Image Magic solved the problem., but I'm still curious why GD library can't handle such big images. Is there any way to solve this issue in a different way? I don't want to be dependent on third party libraries. I would rather use a standard PHP setup (in case of deploying the site on a shared hosting where it's not possible to install custom PHP extensions).

wube
  • 923
  • 2
  • 10
  • 22
  • 1
    Check your error log for errors. A potential candidate is that PHP ran out of memory. – Halcyon May 06 '16 at 14:57
  • I'm afraid it's not a memory-related issue. I even tried to increase the memory limit to 512. There's nothing in the error log. I check both: Apache and PHP log files. I've just updated my previous post. I found a workaround - replacing GD library with Image Magick helped. – wube May 06 '16 at 14:59
  • That doesn't prove anything, maybe GD required 513mb. Check the error log and you'll know for sure what happened. – Halcyon May 06 '16 at 15:01
  • @Halcyon You were right! My assumption was wrong. I thought that 512MB is an insanely high value (but I'm not ashamed about my assumption, I know [a guy](https://en.wikiquote.org/wiki/Talk:Bill_Gates) who thought that 640 kB is enough ;)) I've increased the memory limit to 2048 and set the DG library as a default. it was able to rescale a large image after I've changed the limit. But I didn't find anything in logs. I've checked both: PHP and Apache logs. So it appears that GD is more memory-consuming (at least for this kind of tasks). – wube May 06 '16 at 15:15

4 Answers4

3

If you have upgraded the PHP version. This might cause the old plugin to do so. Same thing happened with me. I upgraded php 5.6 to PHP 7 and same error had occur. When i reinstall the PHP 5.6 it started to work normally.

kd patel
  • 607
  • 1
  • 6
  • 15
0

Try this:

In wp-config.php change this:

define( 'WP_DEBUG', false);

To

define( 'WP_DEBUG', true );

For me works!

Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
alejus
  • 189
  • 1
  • 3
0

I have tried most of the thing which are possible still not working, after all, the research I have checked plugin folder disabled and checked its working for me, please disable one by one plugin and check. It's work for me. thanks :)

you can rename to the plugin folder name ( plugins to plugins_old )

Thanks

dev_ramiz_1707
  • 671
  • 4
  • 20
-2

This is a Server BUG. If you dont't change php.ini, or .htacess, try Upload a PNG file. This tricks work for me!

enter image description here