Tested the image validation in hidden link and it is working fine. Many thanks.
However, I'm not sure why the form is allowed to submit when there are errors in the image field.
Also, not sure whether this is a bug for this field as I'm sure looking at the existing tickets, these kind of validations are requested by many and none of them found it as an issue?
I'm happy to have a new ticket but would be good if it is handled by you since I do not need to go through these for one more time.
To reiterate the issue, image fields in post form and user form are able to submit (Click twice) after validation of the images (dimension and size) is done and not meeting the validation criteria.
Added the code provided by you but not working as expected.
Tested in page "hidden link" with the below steps:
1. Code snippet "post_form_image_validation" - Reduced the file size to 1024 KB for image one (1. Property Image One) only and remaining are with more than 5 MB.
2. Added images in fields "1. Property Image One", "2. Property Image Two" and "3. Property Image Three" with image files more than 1 MB.
3. After clicking the submit button it says, the file size for "1. Property Image One" is more than 1 MB which is expected.
4. After clicking the submit button one more time without correcting the images, it is showing the below error for all the image fields.
Property Image One: Please re-upload your image
Property Image Two: Please re-upload your image
Property Image Three: Please re-upload your image
Although the fields "Property Image Two" and "Property Image Three" contains the correct images with all the conditions met, still the above errors are showing.
The main issue is that on our end and this was escalated is that the fields should be cleared after a failed validation.
Given that its the default php upload then no files were uploaded so the items needed to be re-attached. So its working correctly because after a failed submit all the upload fields will lose their values.
I understand what you are trying to say technically.
But when the user submits the images, let's take the same example while they submit the size more than expected (more than MB) for only one image field, and the error message shows to upload the new image for all the image fields (second image filed & third image field) it will not be a good user experience.
I do not want user to re upload every image when the validation is failed only for one image.
This is exactly the case, not much else we can do because they will need to re-upload back all the images because of how the php default upload works.
The only way I can think of working around this is to use the AJAX upload which will give them the media library interface to upload the images and the verification would happen immediately on upload.
Our development team is working on fixing the issue with the php upload not clearing the fields. What should happen is that after the failed submit all your uploaded images need to be re-uploaded, hence why when you submit the form again after the failed validation.
The fields are actually still empty even though you see the filename below the field.
I actually dont have good news on this one. While the devs are aware of this issue and its been discussed on.
I'm not seeing where they have proposed a timeline for the fix so I cannot give any guarantees as to when this will fix.
My advise here until this is fixed is to provide an adequate feedback the users so they know that they will need to re-upload all the images after a failed validation.
Initially I have planned to create this section using image field (repeated), there is some issue "Validate the image field (Repeating) in the Post Form in Tool set" due to which I have changed to image fields (non repeated) for time being.
However, there is an issue again in this field as well which is very unfortunate.
Instructing customers to re-upload the images is a poor customer experience.
Please inform to the development team and let me know the ETA please.