2/22/18 UPDATE: The awesome developer of the GF Upload to Email Attachment plugin is working on updating the plugin to do this without modifying the plugin.
One of our clients needed a form for their WordPress website that would enable visitors to submit photos that could be attached within the notification email. The request was problematic, in that the images being submitted were exceeding the file attachment size limit. If you run into a similar situation, here is a step-by-step tutorial of our solution to the problem.
STEP ONE – Install the Plugins
First, you will need to install the following WordPress plugins:
STEP TWO – Plugin Modification
The next step is to modify the GF Upload to Email Attachment plugin. As a rule, modifying plugins is a big “no-no”, but in this case, it provided the right solution to the client’s need. Create the notification within Gravity Forms and make sure the name of the notification ends with “GFUEANZ”, per the GF Upload to Email Attachment plugin installation instructions.
STEP THREE – Line Modification / Addition
Modify/add the following lines in gf-upload-to-email-attachment.php within the GF Upload to Email Attachment plugin folder:
After line 33, add the following line:
$upload_root = str_replace("/gravity_forms","/cache/gravity_forms",$upload_root);
What it will do: The WPThumb plugin resizes images and stores them in a cache folder. This change updates the plugin to point to the WPThumb folder instead of the usual Gravity Forms folder.
After line 36, add the following line:
$url = wpthumb( $url, 'width=800&height=800&crop=0&jpeg_quality=70' );
What it will do: This uses the WPThumb plugin to resize the image to a maximum of 800 pixels tall by 800 pixels wide and sets the compression quality to 70. You can adjust these numbers for your specific needs.
After lines 45 and 52, add the following line:
$uploaded_file = wpthumb( $uploaded_file, 'width=800&height=800&crop=0&jpeg_quality=70' );
What it will do: Provide the same functionality for multiple images.
STEP FOUR – Bring On The Photos!
Once completed, all images, uploaded through a Gravity Forms form, will be resized and attached to the email notifications.