[resolved] Fatal error when trying to resize images? (2 posts)

  1. Tevya
    Posted 4 years ago #

    I'm using this code in my functions.php file to resize images to the "large" size specified in Settings>Media when the user uploads the image:

    	/* limits image size to large setting */
    function replace_uploaded_image($image_data) {
        if (!isset($image_data['sizes']['large'])) return $image_data;
        // paths to the uploaded image and the large image
        $upload_dir = wp_upload_dir();
        $uploaded_image_location = $upload_dir['basedir'] . '/' .$image_data['file'];
        $large_image_location = $upload_dir['path'] . '/'.$image_data['sizes']['large']['file'];
        // delete the uploaded image
        // rename the large image
        // update image metadata and return them
        $image_data['width'] = $image_data['sizes']['large']['width'];
        $image_data['height'] = $image_data['sizes']['large']['height'];
        return $image_data;

    It works great most of the time. However, if the image is too large, it gives this error:
    Fatal error: Out of memory (allocated 67371008) (tried to allocate 16000 bytes) in /home/folderhere/public_html/wp-includes/media.php on line 254

    I assume that not enough memory is available to process the resize in these instances. Can somebody point me to what settings on my hosting, would need to change in order to give it enough memory, so it would work correctly?

  2. Tevya
    Posted 4 years ago #

    Nevermind, I posted too quickly, I found other threads addressing this. Looks like Hostgator's hosting sucks. Can't adjust anything above 64M under any conditions. And their solution is always the same: "pay us more money by upgrading to a VPS."

Topic Closed

This topic has been closed to new replies.

About this Topic