PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Post image maximum size

  1. hamedhemmati
    Member

    Can a post image resize be added to the advanced section so large images get automatically resized to the maximum allowed? I have a plugin that does that for when I add picture through the media manager but it's not enforcing it when images are added via gravity forms.

    This will save a lot of server space when large images are uploaded by users that don't know how to resize their images.

    Posted 12 years ago on Wednesday April 27, 2011 | Permalink
  2. Gravity Forms doesn't do any image resizing, but this plugin works very well to do what you want. Several folks have used it to do just what you're asking about.

    http://wordpress.org/extend/plugins/resize-at-upload/

    Posted 12 years ago on Wednesday April 27, 2011 | Permalink
  3. hamedhemmati
    Member

    That's actually the plugin I have but for some reason it doesn't resize images that I upload through gravity forms. It only seems to work when I upload with media manager itself.

    Posted 12 years ago on Wednesday April 27, 2011 | Permalink
  4. Odd, last report I got was that it worked fine.

    http://www.gravityhelp.com/forums/topic/can-i-edit-image-dimensions-after-users-has-submitted-image-and-form#post-13919

    You might consider another plugin like the one below.. or I'm sure there are other choices.

    http://wordpress.org/extend/plugins/max-image-size-control/

    Posted 12 years ago on Wednesday April 27, 2011 | Permalink
  5. hamedhemmati
    Member

    I read through that forum and I think what they were trying to do is display a resized version of the image which is working on my end just fine. What I would like to do is get rid of the original size which is taking a lot of space on the server and can't be used in anything since it's just way too large for web content. The resize at upload does that when you do it through media manager by not when you do it through gravity forms. The other plugin you suggested doesn't remove the original size even if you do it through media manager.

    Posted 12 years ago on Wednesday April 27, 2011 | Permalink
  6. We will have to look into this and see what theMedia Manager is doing differently. Right now it isn't an option, the original size is stored as the original size. The Media Manager than resizes the image to the appropriate media library sizes based on your settings.

    Posted 12 years ago on Wednesday April 27, 2011 | Permalink
  7. hamedhemmati
    Member

    Thanks guys I will try to look into this myself as well and see if I can figure something out.

    Posted 12 years ago on Wednesday April 27, 2011 | Permalink
  8. jimbo
    Member

    Is there any progress on this problem? I need this also. The original image is taking to many space on the server especially if people are puting up 2 MB photos. Is there any way to somehow delete the original image and leave the optimized ones instead?!

    Cheers!

    Posted 12 years ago on Thursday May 19, 2011 | Permalink
  9. When you say original image are you referring to the original image size in the Media Library or the original image stored on the server by Gravity Forms? Because Gravity Forms stores it's file separate from the Media Library. So you can delete Gravity Forms copy of the file and it won't impact the Media Library.

    Posted 12 years ago on Thursday May 19, 2011 | Permalink
  10. jimbo
    Member

    Just what I needed. Is there a way to automatically delete the image from gravity image folder? :D

    Posted 12 years ago on Thursday May 19, 2011 | Permalink
  11. Right now there is not a way, but we can look into adding an option so that the image is deleted immediately rather than stored with the entry data.

    Posted 12 years ago on Thursday May 19, 2011 | Permalink
  12. jimbo
    Member

    Hey Carl, I found this piece of code which does the trick but doesn't keep the aspect ratio of the image. It crops it to the size ( large: max height: 500px, max width: 800px) it doesn't keep the aspect ratio. Can You please help?

    Hey all,

    function replace_uploaded_image($image_data) {
        // if there is no large image : return
        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
        unlink($uploaded_image_location);
    
        // rename the large image
        rename($large_image_location,$uploaded_image_location);
    
        // update image metadata and return them
        $image_data['width'] = $image_data['sizes']['large']['width'];
        $image_data['height'] = $image_data['sizes']['large']['height'];
        unset($image_data['sizes']['large']);
        return $image_data;}
        add_filter('wp_generate_attachment_metadata','replace_uploaded_image');
    Posted 12 years ago on Thursday May 19, 2011 | Permalink
  13. Jimbo, I needed to resize image after upload too, this is what I did : scales to max width 600 ( for my needs - customize where needed )

    http://www.chopapp.com/#n9bqd41c

    Posted 12 years ago on Wednesday June 29, 2011 | Permalink
  14. I found and tried the same function code as above by jimbo. It WOULD do exactly what I need, which is delete the original file and rename the 'large' file to the original file's name so that any WP gallery links, etc would still find an image.

    However, when I upload images via the GF form (and BTW this is on a MU network site), the image gets put in /2011/07/filename.jpg every time. This is September so they should be uploading to /2011/09/filename.jpg. The function above finds the original file and deletes it (not sure why), but the $large_image_location returns the /2011/09 directory (which it seems it should), but there's no file there because it got uploaded to /07.

    Feels like a bug to me, but I may not be understanding how GF handles uploads.

    Thanks for any input.
    Brett

    Posted 12 years ago on Thursday September 15, 2011 | Permalink
  15. Apparently between GF updates and WP updates something got sorted out, because I just tried the exact code above provided by Jimbo and my "large" image uploaded via Gravity Forms can be controlled with the Settings -> Media Large Size Max Width setting.

    For instance, I set the Max width in WordPress settings to 640. I then uploaded a 1624x1080 image that was 607kb and it ended up being 640x425 at 147kb (and I also have the medium and small sized images crunched by WP.

    I was glad this method worked, because I was NOT able to get a plugin solution to work. I tried "Imsanity" which works great going directly through the media library or post upload, but not through GF forms.

    Posted 12 years ago on Thursday February 16, 2012 | Permalink