ThemeShaper Forums » Thematic


Allowed memory size exhausted when uploading large WordPress images

(2 posts)
  • Started 13 years ago by Kyle
  • Latest reply from Devin
  • This topic is not resolved
  1. Kyle

    When I tried to upload an image using WordPress's built-in image upload feature, I received this error message:

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 1024 bytes) in /home/trinityl/public_html/church/wp-includes/media.php on line 999

    The image is 1.7 MB in size and has dimensions of 2875 x 2156.

    I checked line 999 of media.php. Here's the section of the code, which includes line 999 (bolded).

    * Create new GD image resource with transparency support
    * @since 2.9.0
    * @param $width
    * @param $height
    * @return image resource
    function wp_imagecreatetruecolor($width, $height) {
    $img = imagecreatetruecolor($width, $height);
    if ( is_resource($img) && function_exists('imagealphablending') && function_exists('imagesavealpha') ) {
    imagealphablending($img, false);
    imagesavealpha($img, true);
    return $img;

    I tried uploading other images that were larger in file size than 1.7 MB, and I received no error message.

    I then tried uploading other images that were larger in their dimensions. When I tried to upload a 3000 x 3000 image, I received this similar error message:

    Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 12000 bytes) in /home/trinityl/public_html/church/wp-includes/media.php on line 253

    Notice that the error is on line 253 this time. Here's the section of media.php that includes line 253 (which I've bolded again).

    * Load an image from a string, if PHP supports it.
    * @since 2.1.0
    * @param string $file Filename of the image to load.
    * @return resource The resulting image resource on success, Error string on failure.
    function wp_load_image( $file ) {
    if ( is_numeric( $file ) )
    $file = get_attached_file( $file );

    if ( ! file_exists( $file ) )
    return sprintf(__('File “%s” doesn’t exist?'), $file);

    if ( ! function_exists('imagecreatefromstring') )
    return __('The GD image library is not installed.');

    // Set artificially high because GD uses uncompressed images in memory
    @ini_set('memory_limit', '256M');
    $image = imagecreatefromstring( file_get_contents( $file ) );

    if ( !is_resource( $image ) )
    return sprintf(__('File “%s” is not an image.'), $file);

    return $image;

    Yes, I realize that it appears I could just resize images before uploading them, but a very "non-technical" blogger of mine is having this issue, and I'm not sure he'd even know how to resize images before uploading them. Besides, I guess I'd like to know why I can't upload images with very large dimensions.

    I apologize for the length of this post, but I wanted to be as specific as possible. Thank you in advance!

    Posted 13 years ago #
  2. Try reading this post of mine:

    Sometimes it's as simple as increasing the memory limit in the config.php:

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

    Otherwise read on to do it through php.ini.

    There's also a lot of posts in the WordPress forums about this subject if you give them a search.

    Posted 13 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.