[wp-hackers] Memory size error when uploading images

Lonny K lonnyk at gmail.com
Mon Mar 7 21:16:24 UTC 2011


Christian,

I am not so sure that your issue has to do with the upgrade. Can you
please try a smaller image that you have added previously and let us
know if it works?

Looking into this I did find a bug that is related. If you are in the
admin then WordPress will set the PHP memory_limit in
/wp-admin/admin.php. It calls the filter 'admin_memory_limit' and
defaults to 256M. In wp-includes/media.php we also set the PHP memory
limit to 256M, but we do not pass it through a filter. This means that
anytime we go through the wp_load_image function we are immediately
reduced to a 256M memory_limit - regardless of where it was previously
set. A bug report has been opened for this:
http://core.trac.wordpress.org/ticket/16789

2011/3/2 Christian Gundersson <christian at buro2.se
<http://lists.automattic.com/mailman/listinfo/wp-hackers>>

>* Yes, but only through wp-config.php and .htaccess. I don't have access to*>* php.ini unfortunately and the webhost is closed until tomorrow.*>**>* But I'm not sure that it really is a memory size problem. All reported*>* issues like this that I have read, where the allocated size is smaller than*>* the limit, have not been resolved by increasing the PHP memory allocation*>* limit. I'll try that just to be sure tomorrow, but I'd like to get a heads*>* up on the problem if that doesn't solve it :)*>**>* //Christian*>**>**>**>* 2011/3/2 Martin Buckley <martin at buckleymail.com <http://lists.automattic.com/mailman/listinfo/wp-hackers>>*>**>* Have you tried increasing your PHP memory allocation?*>>**>>* -----Original Message-----*>>* From: wp-hackers-bounces at lists.automattic.com <http://lists.automattic.com/mailman/listinfo/wp-hackers> [mailto:*>>* wp-hackers-bounces at lists.automattic.com <http://lists.automattic.com/mailman/listinfo/wp-hackers>] On Behalf Of Christian*>>* Gundersson*>>* Sent: Wednesday, March 02, 2011 9:28 AM*>>* To: wp-hackers at lists.automattic.com <http://lists.automattic.com/mailman/listinfo/wp-hackers>*>>* Subject: [wp-hackers] Memory size error when uploading images*>>**>>* Hi!*>>**>>* I have a problem and can't seem to get the suggested solutions from the*>>* internets to work. Anyone got a hint I'll be glad to listen...*>>**>>* I get the error below when I upload an image through the media library*>>* (either directly or from within a post).*>>**>>* *Fatal error*: Allowed memory size of 33554432 bytes exhausted (tried to*>>* allocate 5004 bytes) in *wp-includes/media.php* on line *254**>>* **>>* **>>* A very weird message since it tries to allocate a smaller amount than the*>>* limit, but anyhew.*>>* **>>* **>>* I've looked in the wp_postmeta table after uploading an image and the*>>* entry for _wp_attached_file is there and looking as it should. However, the*>>* accompanying entry for _wp_attachment_metadata is missing. It feels as*>>* though the upload procedure fails somehow but the image still gets uploaded.*>>**>>* The codeline mentioned in the error message is $image =*>>* imagecreatefromstring( file_get_contents( $file ) );*>>**>>* I can see the image in the media library and I can also attach it to*>>* posts, but only in it's full size. Previously uploaded images work like they*>>* should, and between the last uploaded image that works and now the only*>>* change is a WP upgrade from 3.0.3 to 3.1.*>>**>>* Any hints or pointers as to what could be causing this would be helpful.*>>* The support forum suggestions are not helping, neither is google...*>>**>>* I'm running WP 3.1 if it's of any interest. Sorry for the long post.*>>**>>* Regards*>>* //Christian*>>**>>* **>>* **>>* _______________________________________________*>>* wp-hackers mailing list*>>* wp-hackers at lists.automattic.com <http://lists.automattic.com/mailman/listinfo/wp-hackers>*>>* http://lists.automattic.com/mailman/listinfo/wp-hackers*>>**>**>**


More information about the wp-hackers mailing list