Looks like image resize is not working well

The question:

Im searching for some clue about this behavior? I think it is a PHP memory_limit or WP define(‘WP_MEMORY_LIMIT’, ‘X’) issue?

Sometimes images are resized and sometimes not, in other scenarios the browser crash:

  1. Im using Dreamhost as shared hosting, and their 7 upload limit.

  2. Error printed with an uploaded image of 6.4MB of size and with a width and height of: 11684×3855:
    Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 46736 bytes) in /PATH/wp-includes/media.php on line 254

  3. Other users reports the same issue with files, for example, of 3MB but with higher width and height (superior to 2000px or 3000px).

Any help is welcome.

Thanks in advance.

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

I’ve had the same issue in the past when uploading very large images. When it comes to crunching the image it fails and shows HTTP ERROR in red. However other images continue to load. It wasnt file size where it would fail but rather the pixel width and height of the images.

By default PHP settings, the most GD libary can handle per image is 1,000,000 pixels which is 1024px*1024px

Did you know: 8,000 pixels times 8,000 pixels times four bytes for truecolor equals a walloping 256 megabytes. Now I know no shared hosting webhost that allows you a PHP memory limit of 256MB

The only solution I was able to find, of which I’m offering to you, is to reduce the size of the images beging uploaded. Alternativly convince your webhost to up PHP memory limit, which is unlikely.

Method 2

As @Brady said alot of settings go only to 1024 x 1024 this will probably change in the future as stats for resolutions, browsers, Internet speeds, etc change and show that alot of people are running better or newer systems

reduce the image size as most users do not need to view a image that is bigger then 1024 x 1024. I usually use the 800 x 600 or bigger but less then 1024 x 1024. Most of my images though are smaller


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment