Skip to content

Commit fccdfcd

Browse files
authored
gpfup-enforce-exact-dimensions.js: Added snippet to enforce exact dimensions on file upload.
1 parent 49ab284 commit fccdfcd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Gravity Perks // File Upload Pro // Enforce Exact Width or Height
3+
* https://gravitywiz.com/path/to/article/
4+
*
5+
* By default, the exact exact width *and* height settings applying cropping for conformity.
6+
* This snippet enforces exact dimensions and any image other the specified width and height is rejected.
7+
* The dimensions which are needed to be applied for exact match must be saved on Min Dimensions settings.
8+
*
9+
* Instruction Video: https://www.loom.com/share/4b28e2dbdbbb4b399b7220d3d77d71f5
10+
*
11+
* 1. Install this snippet with our free Code Chest plugin.
12+
* https://gravitywiz.com/gravity-forms-code-chest/
13+
*/
14+
window.gform.addFilter( 'gpfup_meets_minimum_requirement', function ( meetsMinimum, imageSize, formId, fieldId, GPFUP ) {
15+
if ( imageSize.width == GPFUP.minWidth && imageSize.height == GPFUP.minHeight ) {
16+
return true;
17+
}
18+
return false;
19+
} );
20+
21+
window.gform.addFilter( 'gpfup_strings', function( strings, formId, fieldId ) {
22+
// REPLACE 1 with the field id of your File Upload Pro field
23+
if ( formId != GFFORMID && fieldId == 1 ) {
24+
return strings;
25+
}
26+
27+
// Alter the message, if needed.
28+
strings.does_not_meet_minimum_dimensions = 'This image does not meet the exact dimensions: {minWidth}x{minHeight}px.';
29+
return strings;
30+
} );

0 commit comments

Comments
 (0)