Require Camera for Uploads

Want to ensure that the user is uploaded a fresh image taken directly from their camera? This snippet will force use of the camera and prevent selecting an existing image on mobile devices.

Instructions

  1. Install this snippet with our free Custom JavaScript plugin. https://gravitywiz.com/gravity-forms-code-chest/

Code

Filename: gpfup-require-camera.js

/**
 * Gravity Perks // File Upload Pro // Require Camera for Uploads
 * https://gravitywiz.com/documentation/gravity-forms-file-upload-pro/
 *
 * Want to ensure that the user is uploaded a fresh image taken directly from their camera?
 * This snippet will force use of the camera and prevent selecting an existing image on
 * mobile devices.
 *
 * Instructions:
 *
 * 1. Install this snippet with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 */
gform.addAction( 'gpfup_uploader_ready', function( gpfup ) {
	gpfup.Uploader.bind( 'PostInit', function() {
		$( gpfup.$field ).find( 'input[type="file"]' ).attr( 'capture', 'camera' );
	}, gpfup );
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.