Problem:
I want to display my search results to different page
Solution:
With view block you can chose different setting what you want to display, either search for, search results or both.
I've set the setting to display only search form and configured the search result page as you can see with the following screenshot:
=>https://nimb.ws/Twv5b8
And on your "Home Search Result" page I've added the view to display only search results:
=> https://nimb.ws/ANsjbD
Problem:
The user would like to validate an image field(repeatable) in a Toolset form for the image type, size, dimensions, and number of images
Solution:
This will require custom code. Check this example code:
add_action('cred_form_validate', 'my_image_validation_func',10,2);
function my_image_validation_func($error_fields, $form_data) {
// all the valid file types
$file_types = array('image/jpeg','image/png','image/jpg');
$max_size = 5 * 1024 * 1024;
$forms = array( 1806 );
// Field data are field values and errors
list($fields,$errors)=$error_fields;
if (in_array($form_data['id'], $forms ) && (isset($_FILES['wpcf-book-images']['type']))) {
// 1. Minimum number of photos is '3'.
if ( count( $_FILES['wpcf-book-images']['name'] ) < 3 ) {
$errors['wpcf-book-images'] = 'Add at least 3 images';
return array( $fields, $errors );
}
// 2. Dimensions of the photo should be at least 350 (height) x 350 (width).
foreach ( $_FILES['wpcf-book-images']['tmp_name'] as $tmp_image ) {
$sizes = getimagesize( $tmp_image );
if ( $sizes[0] < 350 || $sizes[1] < 350 ) {
$errors['wpcf-book-images'] = 'An image is too small. Images should be at least 350x350';
return array( $fields, $errors );
}
}
// 3. The file types should be JPG, PNG and JPEG.
foreach ( $_FILES['wpcf-book-images']['type'] as $type ) {
if ( !in_array( $type, $file_types ) ) {
$errors['wpcf-book-images'] = 'Image file type is not supported: ' . $type;
return array( $fields, $errors );
}
}
// 4. Maximum file size should be 5MB.
foreach ( $_FILES['wpcf-book-images']['size'] as $size ) {
if ( $size >= $max_size ) {
$errors['wpcf-book-images'] = 'An Image is too big. Images should less than 5MB';
return array( $fields, $errors );
}
}
}
//return result
return array($fields,$errors);
}