Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 5 replies, has 3 voices.

Last updated by Prosenjit Barman 1 year, 10 months ago.

Assisted by: Prosenjit Barman.

Author Posts
April 5, 2023 at 1:07 pm #13410509

andreaP-96

I am trying to:
show custom term image with specific size on front page

Link to a page where the issue can be seen: hidden link

I expected to see:
resized image in all languages

Instead, I got:
correct image size on default language, wrong in other languages

This happens only with this size:
add_image_size( 'homecategory2', 600, 675, true );

All other sizes works correctly. I already tried to regenerate thumbnails.

it-Annotazione 2023-04-05 150525.jpg
de-Annotazione 2023-04-05 150559.jpg
April 5, 2023 at 8:41 pm #13414075

Ahmed Mohammed
Supporter

Timezone: Africa/Cairo (GMT+02:00)

Hi there,

Thank you for contacting WPML support!

I can see the thumbnail size in the original language quals to 600 x 675, while in the secondary language is 600 x 400.

You mentioned that the issue is happening only with one size, and other sizes are working correctly. Could you please let us know if the other sizes were defined the same way?

Additionally, if we would like to reproduce the issue, could you please provide us with the steps to that we can troubleshoot what is going on?

Looking forward to hearing back from you.

April 6, 2023 at 7:10 am #13416649

andreaP-96

Yes, he other sizes were defined the same way:

<?php echo types_render_termmeta( "cathome-photo", array( 'term_id'=> $category->term_id, 'size' => 'homecategory2' )); ?>

<?php echo types_render_termmeta( "cathome-photo", array( 'term_id'=> $category->term_id, 'size' => 'homecategory' )); ?>

April 7, 2023 at 12:29 pm #13427119

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hello There,
I hope you're doing fine.

I understood what you're looking for. If the custom image size is working on the term in the default language but not in other, then can you please check your code again and make sure that the code is not limited to the default language?

For example, if the Term ID of the default language is used on the code, then the code should work only for that specific term. As the Term ID is different in each language, you need to make sure that the code you're using is also capable of handling the translated Term ID. I hope you can understand my point.

If you want, you can try setting the image size for the other languages using wpml_language_code hook. Please check the link below for more information about the hook.

- https://wpml.org/wpml-hook/wpml_current_language/

Instead of null, you can set the language code and then check if the image size works for that language.

Let me know the update. I will be happy to assist you if you need further assistance in this matter.

Best Regards,
Prosenjit.

April 11, 2023 at 7:08 am #13442195

andreaP-96

Hi,
the code is not limited to the default language.

This code works:
<?php echo types_render_termmeta( "cathome-photo", array( 'term_id'=> $category->term_id, 'size' => 'homecategory' )); ?>

This one no:

<?php echo types_render_termmeta( "cathome-photo", array( 'term_id'=> $category->term_id, 'size' => 'homecategory2' )); ?>

And both are in the same page.

April 12, 2023 at 4:37 am #13451769

Prosenjit Barman
Supporter

Languages: English (English )

Timezone: Asia/Dhaka (GMT+06:00)

Hi There,

Thanks for your response. Since one custom size is working properly and the other is not, then there must be some difference between both that is preventing the other one to work properly. Please check the code, more specifically, check if any condition is applied there or not.

You can also check by using the WordPress default sizes instead of the custom size and check if it works or not. If that works, then you may need to adjust the code for the Custom size.

Also, since you're defining the Term by hardcoding into the code("Cathome-photo"), if you have translated the Term to other languages, then kindly try also using the Translated Term. I hope it will help.

However, please be informed that providing support for the issues that happen due to the custom code is beyond the scope of our support. Therefore, I'm afraid I may not be able to assist you much with the custom code. But, I will be happy to share suggestions with you.

If you need assistance with custom code, then you can hire a certified developer of WPML who can help you with the custom solution and fix things as per your needs.

You can find one here: https://wpml.org/contractor

Best Regards,
Prosenjit