Skip Navigation

[Resolved] CRED featured image resizes after backend validation with cred_form_validate

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a CRED form that includes a featured image field. On the backend, I have set up some validation using the cred_form_validate API. If backend validation returns some error, the page refreshes and the featured image is displayed at a large size. Before submission, or when editing the post with CRED later, the image is shown as a thumbnail.

Solution: Update to Forms 2.5.7 once it is released to get a fix that does not require custom CSS.

This support ticket is created 6 years, 1 month ago. 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 5 replies, has 2 voices.

Last updated by Christian Cox 3 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#621821

Hi Christian,
I did several tests before writing to you, let's talk about the "add content" module.

the choice of Taxonomies is ok, but something strange happens.
if I do not choose the Taxonomy (I tried to generate an error to see the operation) it happens that the image of the post increases in size, goes from miniature (150x150px) to medium size (300x300px).

I tried to select taxonomies and generate a different error by not inserting the post title and the image does NOT change in size.

It works out in my opinion, establishing the size of the image in the shortcode of the Cred module.

here is the shortcode part of the form:

<div class="form-group">
		<label>[wpml-string context='cred-form-aggiungi creatura originale-348' name='foto']foto[/wpml-string]</label>
		[cred_field field='_featured_image' value='' urlparam='' output='bootstrap']
	</div>
#621824

I can replicate the same behavior with any backend validation, so I do not think this is specific to the taxonomy validation we added. For example, add this custom cred_form_validate function and the same image resize behavior can be seen:

add_filter('cred_form_validate','func_validate_taxonomy_select',10,2);
function func_validate_taxonomy_select($error_fields, $form_data)
{
    //field data are field values and errors
    list($fields,$errors)=$error_fields;
  
    //validate if specific form
    if ($form_data['id']==348 or  $form_data['id']==349)
    {
         
        $errors['_featured_image'] = 'Some test error';
            
          }
    //return result
    return array($fields,$errors);
}

I'm not sure if this is a bug, or the intended behavior. Let me reach out to my 2nd tier supporters for some clarification here, and I will update you when I have some new information to share.

#622128

Just a quick update to let you know we have reported the issue to our developers as a potential bug. Please stand by and I will update you as soon as I have some additional information. In the meantime the image upload and save process does not appear to be broken, just the display of the image when cred_form_validate returns some error.

#631407

I have some custom CSS you can add to the CRED form to prevent this image resize:

.js-wpt-credfile-preview img {
    max-width: 150px;
}

Please add this CSS and let me know if the issue is not resolved.

#1627939

Hi, just a quick update to let you know the upcoming release of Forms 2.5.7 will include a fix for this issue and the custom CSS code here should no longer be necessary.

#1668381

Please note that Forms 2.5.7 has been released and the CSS override should no longer be needed. Please let me know if the problem is not completely resolved after updating to the latest versions of all Toolset plugins.

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