Hello,
Thanks for the feedback and sorry for the late answer. This is a missing feature from ACF due to a small bug in the JavaScript when using Image/File upload in basic mode.
I found the bug and reported it to the ACF developer which acknowledged it for a future patch. In the meantime, I plan to ad the fix within ACF Extended, and then remove it once ACF update its code.
Here is the report:
Hello,
Since I’m working on some additional settings for the File/image fields, I just stumbled upon an old bug that I thought was just a missing feature.
Many of us are using ACF Form on front-end and switch the Uploader Field to “Basic Mode” in order to hide the WP Media modal from the visitors. One downside of that method is that it doesn’t include the “Min/Max File Size” settings with the ajax validation. I always thought that was just a simple missing feature, but it isn’t! In fact, the code actually has everything to handle that validation (actual validation, error message etc…).
The problem come from the following Javascript code located in /assets/js/acf.js:1943
:
var file = acf.isget( $input[0], 'files', 0);
Here, the code is trying to get the files object from the <input type="file" />
value, using the awesome acf.isget()
helper. However, the Javascript FilesList property is not an object like others, and it can’t be checked properly using that helper. In order to check and get the FilesList property, we need to use length. Knowing that, here is a fix proposal:
var file = $input[0].files.length ? acf.isget($input[0].files, 0) : false;
This will unlock the rest of the Javascript which will correctly set the filesize, and thus, allow ACF to correctly check the size during the Ajax Validation process and render the error message if needed.
Video demo: https://i.imgur.com/9LZdLct.mp4
Have a nice day!
Regards.
Regards.