Thumbnail Generation PHP Memory Limit NextGEN Gallery
When uploading a set of admittedly large images using NextGEN Gallery to my WordPress site I exceeded my web hosts default memory usage allocation for PHP applications. The error was:
Follow thumbnails could not created. sample.jpg (Error : Exceed Memory limit. Require : 80.65 MByte)
This issue can be resolved by increasing the memory usage allocation at a per-plugin level for PHP applications that require more grunt than others. It’s quick and easy!
- Open an FTP connection to your root WordPress directory
- Open
/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.phpwith your favourite text editor (e.g. UltraEdit, etc.) - On line #168 un-comment (remove the
//) from before@ini_set('memory_limit', '128M'); - Save and upload changes
- Delete image/s that failed to generate a thumbnail and re-upload using NextGEN Gallery’s standard Upload Images feature
If you find 128MB is too ‘conservative’ this can be increased again to any figure of your liking, I find 128MB appropriate for most commercial and personal usage but if you’re a HD photographer then you’re going to hit this limit very quickly… that’s it!
63 Comments »
Trackbacks
- Travels Through the Vast Expanses of Monotony » My Very First Post and a Problem Solution All At the Same Time!
- Thumbnail Generation PHP Memory Limit in NextGEN Gallery « Sun Grass
- johnjcamilleri.com » Wordpress NextGEN Gallery – Thumbnail Generation PHP Memory Limit
- [ZT]Thumbnail Generation PHP Memory Limit in NextGEN Gallery - Green Vegs Blog
- NextGen Memory Limit « Cludgie's Colossal Waste Of Time!
- ???????? ?????? ??? ????????????? ??????? NextGen | Ninjaside
- Nextgeneration Galerie: Thumbnail-Erzeugung scheitert — Internetdienste Berlin
- Problems with your NextGEN Photo gallery? « Ernst Designs, LLC
Leave a comment
The perfect comment is interesting, on-topic and/or highly amusing.







Michael – I have spent over a day trying to solve this issue – messing around with .htaccess, php.ini and memory limits. This simple solution solved the problem immediately. Thankyou so much!
Hey Bob, sweet to hear it helped. How easy would it be to manage PHP script memory limits at a WordPress Administrator level under Settings > Memory, that would be great! Add it to the wish list.
THANK YOU!!! I only last about 2 hours … but THANK YOU … whew … I’ll make sure to bookmark this
Michael – Thanks for this solution. I’m new to the wordpress and web stuff so your simple solution to this problem really was amazing. I probably came across 20 other sites with solutions that just didn’t work for me. I’m not sure about blog etiquette, but I linked to your page from mine so that hopefully others will find you. If you look and I didn’t do it according to standards, let me know and I’ll happily fix it.
Hi Tommy,
Thanks for your kind words, I’m glad it helped. Your site is having a few presentation difficulties of its own…
hi,
I have question, if I have a lot of picture, and running professional blog adding pictures everyday. then am i going to hit this limit , if yes, then how to make it unlimited?
Hi Ajay,
I don’t this issue will affect you as it only occurs at upload time, I do know there is a refresh thumbnail button within NextGEN that if you check all items may cause this issue but it’s unlikely you will encounter this scenario.
Ty sir. That worked like charm. No more thumbnail sizing issues. You are a huge time saver my friend.
Hi Michael,
Just wanted to say thanks for the fix. Your post maybe nearly a year old but it’s just as relevant today as it was then.
Graham.
Hey Graham, it’s an oldie but a goodie! Just make sure you re-apply the fix after auto-updating NextGEN Gallery… plugin function overrides at a WordPress install level is still only a dream.
Thank you so much for sharing! I really appreciate your time and expertise. What an easy solution to a very frustrating problem. Yours was the only advice that was helpful to me…thanks!
Awesome Carolyn, big thanks go out to the original developers for including the source commenting otherwise I’d never have found it.
Hi!
I also just came over this problem. Thanks god, someone posted a link to here at the wp forum. You really solved me a lot time! And only because of 2 slashes…
Thanks a lot for making this public!
Tom
Thank you, you save hours of my live))
by the way, file name is gd.thumbnail.inc.php
Hey Delpher, thanks for the update I’ll do that now. Glad this fix still holds up!
You might have to deactivate the plugin and the reactivate it for this to work.
I’ve had the same problem as described in the post. Unfortunately, this fix didn’t work for me. I’ve also tried altering the memory_limit with .htaccess but then I get an error 500 right away. I asked my host (one.com) and they told me that they don’t allow users to change the memory_limit. To me, that sounds weird, since it’s the first host that I’ve come across that limits their users to just 24M. But hee, at least they’re cheap.
So, I still get an error with pictures over 600px wide and portrait oriented pictures almost always give the fatal error.
I’ve really had it with this! The first couple of hundred (300) photos worked fine. Is there a workaround or a way to do this while using less memory? Or should I consider changing hosting?
Hi Josh,
That 500 error indicates your hosting provider does not allow you to alter php.ini values, contact them directly and get them to increase your memory_limit value.
Thank you for this fix!
Thank you for this easy fix! I only wasted an hour trying to manipulate memory size with .htaccess. But I’ve learned to start searching the web in case of strange error reports. By the way: your name is very Dutch
Was exactly what I was looking for, thanks!
They should make this an option in the plugin itself…
Worked perfectly thanks!
That did the trick! Thanks!
Lovely! Thank you so much for your to-the-point help!
Hi!
I have a question: If I put away the two // then i receive this error:
Parse error: syntax error, unexpected T_STRING in /var/www/web25/web/fotos/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php on line 160
What shall I do now?
Thanks!!!! I was killing myself trying to figure this one out!!! This solved it for me right away. Awesome.
Cheers.
Thanks for this post. I’ve been searching for the solution for a while.
Thanks again.
Thanks for the entry. Initially I got this one:
img.png (Error : Exceed Memory limit. Require : 80.13 MByte)
After doing the modifications as described above, I now get following error:
Fatal error: Out of memory (allocated 74186752) (tried to allocate 17044 bytes) in /www/htdocs/user/v3.1/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php on line 179
Even adding “php_value memory_limit 256M” to my .htaccess doesn’t work. Could anyone help me, please?
Thanks a lot.
After moving my Blog to another Server i got this problem and solved it with your hint.
Kind regards,
Michael
Your instructions worked! That’s saying a lot for tutorials these days – I found you when I encountered this problem working for a client by Googling “how to increase server memory for nexGEN gallery” — FYI
That did the trick! Thanks so much!
Been bothered by this issue for awhile thanks alot of the solution.
Amazing. I actually held a post that should have gone out by Sunday morning trying to fix this and your solve simply had it working in a minute.
Thanks for the lifesaver.
The result of this left me with: Fatal error: Out of memory (allocated 69206016) (tried to allocate 19968 bytes) in /home/flank/public_html/aquadetail/wp-content/plugins/nextgen-gallery/lib/gd.thumbnail.inc.php on line 351
I’m going to comment back out that line… Thanks though!
Hey Devin, that means your hosting comany is limiting your memory. Contact them to increase it then you can make the same change again.
Great aritcle! This simple solution made the upgrade of server memory and paying more fot it monthly to my provider unneccessary. Thank you very much!
Hey Martin, feel free to send a beer my way in that case from the donation form in the footer region.
After taking away the // I still get “dsc_0004.jpg (Error : Exceed Memory limit. Require : 64.35 MByte)” :S:S why is this?
Thank you so much. I found your post in a Google search and was able to quickly eliminate the errors and get it going.
HI Michael,
I will join here long list of gratitudes and say – thank you for sharing this with rest of us.
Thanks! ver useful for me!
Michael, thanks. Worked a treat. I wonder if I’ll have to do this again when the plugin’s updated?
Hey Rob,
Yes you will need to apply this for each update to NextGEN Gallery, until a switch is added to the database to check this will remain so.
Thanks again, Michael
After I saved the photos in a compressed size, your fix fixed the problem. Thanks so much! (spent a whole day on this…)
Thanks great tutorial, increasing the memory limit this way is easy and it worked for us.
Hey, I just wanted to point out that you don’t actually need to delete all the images and re-upload them. If you go into the “Manage Gallery” page and select your album(s), then select ‘Create New Thumbnails’ and apply it will re-create those thumbnails for you.
Cheers!
Thanks for this.
Thanks buddy! Only solution that worked out of about 8 that I tried!
BTW it was on line 321 for me (maybe notepad++)
Thanks, a real help!
Again, thanks for this help!
Like many other people above me, a big thank you for this simple fix.
Hey Adam, good point. Times have changed since this post was released.
You’re my hero. tks
Hey, thanks so much for the fix! I wish NextGen uncomment that line by default. That would have been so helpful.