Skip to content

Instantly share code, notes, and snippets.

@jordan26
Last active January 8, 2020 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordan26/db4f5b58a63aa8baf0c043cac5764309 to your computer and use it in GitHub Desktop.
Save jordan26/db4f5b58a63aa8baf0c043cac5764309 to your computer and use it in GitHub Desktop.
// This function will render the uploaded image in a dynamically generated <img> tag to preview to the user.
gform.addFilter('gform_file_upload_markup', function (html, file, up, strings) {
// @TODO - Update this url for dev, staging, production server.
var myFilePath = 'https://s3-eu-west-2.amazonaws.com/influx-media/uploads/gravity_forms/9-57660a16a91c9efdb7ff52f24ff6f0b4/tmp/';
var formId = up.settings.multipart_params.form_id,
fieldId = up.settings.multipart_params.field_id;
var fileName = up.settings.multipart_params.gform_unique_id + '_input_' + fieldId +'_'+ file.target_name;
html = "<span class='gallery-image-preview-thumb gallery-image-preview-thumb--media' style='background-image:url(" + myFilePath + fileName + ")';><div class='gform_delete close-icon close-icon__gallery-image-edit-form' onclick='gformDeleteUploadedFile(" + formId + "," + fieldId + ", this);' alt='" + strings.delete_file + "' title='" + strings.delete_file + "'></div></span>";
return html;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment