Skip Navigation

[Resolved] CRED Form Featured Image Validate Upload size not working

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 1 reply, has 2 voices.

Last updated by Minesh 7 months, 4 weeks ago.

Assisted by: Minesh.

Author
Posts
#2641905

I've been using this script, from https://toolset.com/forums/topic/what-is-the-slug-for-a-featured-image/ and it doesn't appear to be working. Logged in users using the CRED from 98 are uploading images as featured images that are not 500px by 500px. Can you assist?

add_filter('cred_form_ajax_upload_validate','my_validation_artist',10,2);
function my_validation_artist($error_fields, $form_data)
{
//field data are field values and errors
list($fields,$errors)=$error_fields;
//validate if specific form
if ($form_data['id']==98)
{
//check if featured image exists o
if (isset($fields['_featured_image']))
{
list($width, $height, $type, $attr) = getimagesize($fields['_featured_image']['field_data']['tmp_name']);

if ($width != 500 && $height != 500) {
//set error message for featured image
$errors['_featured_image'] = 'Image size must be 500 * 500, your image dimensions are '.$width.' * '.$height;
}

}
}
//return result
return array($fields,$errors);
}

#2642083

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I review the reference ticket you shared:
- https://toolset.com/forums/topic/what-is-the-slug-for-a-featured-image/

And with the reference ticket you shared, I see Waqar already shared solution with the following reply:
- https://toolset.com/forums/topic/what-is-the-slug-for-a-featured-image/#post-2635967

Have you tried the solution shared by Waqar with above reply?

#2642133

Thank you! I've now added his script, I thought I had before.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.