Skip Navigation

[Gelöst] CRED Form Featured Image Validate Upload size not working

This support ticket is created vor 1 Jahr, 2 Monaten. There's a good chance that you are reading advice that it now obsolete.

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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 1 Antwort, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 1 Jahr, 2 Monaten.

Assistiert von: Minesh.

Author
Artikel
#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

Sprachen: Englisch (English )

Zeitzone: 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.