Skip Navigation

[Resolved] Free Ad : Feature image doesn’t appear on translated version

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

Problem:
Validate featured image dimension or uploaded image dimension using CRED form

Solution:
With CRED form you can validate your image dimension using the CRED hook "cred_form_validate" or "cred_form_ajax_upload_validate" so that user needs to upload the perfect dimension image and if user uploads different dimension image it will throw the error.

You can find proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/free-ad-feature-image-doesnt-appear-on-translated-version/#post-620394

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_ajax_upload_validate

This support ticket is created 6 years, 9 months 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.

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 8 replies, has 2 voices.

Last updated by PaulS4783 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#620387

When I posted a FREE AD on the Classifieds Reference Site (running WPML), the posting in English was perfect.
I uploaded a feature image and a couple of "gallery images".

However, when I checked the Spanish version, the gallery images were there but the feature image was blank.

BTW is there anyway to force users to upload images of certain dimensions and/or crop uploaded images to a preset size?
When images are all different heights and widths the layout doesn't look so good.

#620394

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - with CRED form you can validate your image dimension using the CRED hook cred_form_validate so that user needs to upload the perfect dimension image and if user uploads different dimension image it will throw the error.

For example - something like this code - you can adjust the code as per your requirement:

function validate_featured_image_size( $field_data, $form_data ){
 
    $form_id = array( 9999); // add IDs of CRED forms
 
    $validate_width = 300; // Edit
    $validate_height = 200; // Edit
 
    if ( in_array( $form_data['id'], $form_id ) ) {
 
        // Split field data into field values and errors
        list( $fields,$errors ) = $field_data;
 
        $check = getimagesize( $fields['_featured_image']['value'] );
 
        if ( $check !== false ) {
 
            $width = $check[0];
            $height = $check[1];
 
            if ( $width != $validate_width || $height != $validate_height ) {
                $errors['_featured_image'] = "Image wrong size";
            }
        }
 
        $field_data = array($fields,$errors);
    }
 
    return $field_data;
}
add_action( 'cred_form_validate', 'validate_featured_image_size', 10, 2 );

Where:
- Replace 9999 with your original CRED form ID

More info:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_form_validate

#620403

OK. Thanks.
I will give this a try.

#620423

Actually you didn't answer the first part of the question.

The feature image isn't appearing on the translated version.

Any advice?

#620425

Minesh
Supporter

Languages: English (English )

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

Well - here is the Doc from WPML that will guide you how you can translate/copy media.
=> https://wpml.org/documentation/getting-started-guide/media-translation/#copying-and-translating-attachments

#620430

Yes, but does this mean I can configure CRED / WPML so that FREE AD posts automatically get the feature image copied to the translated version?

#620433

Minesh
Supporter

Languages: English (English )

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

Yes - you should go to:
=> WPML => Media translation and checkmark the appropriate checkboxes and click on "Start" button.

And also click on "apply" button within the section "How to handle media for new content:" by making sure appropriate check boxes checked.

#620446

OK. That sounds like it covers everything. thank you !!

#622359

I set the media translation within WPML as suggested.
It successfully copied the feature image to translations on EXISTING content.

However, when I tested again by adding a new FREE listing, it didn't copy the feature image.
hidden link
hidden link

Please advise what I should do.