Skip Navigation

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

Problem:
WPML does not allow me to translate images if image sizes are disabled

Solution:

The issue was escalated to our developer's queue and will be fixed in one of the future versions.

In the meantime you can use the next workaround:

- \wp-content\plugins\wpml-media-translation\classes\media-translation\class-wpml-media-attachment-image-update.php

in \WPML_Media_Attachment_Image_Update::resize_thumbnail

Change:

if ( $size['width'] > get_option( 'thumbnail_size_w' ) || $size['height'] > get_option( 'thumbnail_size_h' ) ) {

to

if ( $size['width'] > get_option( 'thumbnail_size_w' ) && get_option('thumbnail_size_w') > 0 || $size['height'] > get_option( 'thumbnail_size_h' ) && get_option( 'thumbnail_size_h' ) > 0 ) {

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

Last updated by rafaelC-28 1 year, 11 months ago.

Assisted by: Dražen.

Author Posts
July 1, 2023 at 6:50 pm #13928043

rafaelC-28

After updating to the latest version, WPML does not allow me to translate images if image sizes are disabled

I am trying to translate images after updating WPML to the latest version. When I go to WPML's Media Translation to specify a new file for the secondary language, I get this error after uploading the file: "Could not calculate resized image dimensions".

The file is actually created on the server, but the button to save changes keeps disabled. If I change a text field, the button is now enabled, but the new file is ignored.

I am a developer and I realized that this problem only happens if image sizes are disabled on Media Settings. hidden link

This website is a testing sandbox I created when I discovered this bug on my live website hidden link

Steps to reproduce (Error):
1. Disable image sizes on WordPress.
2. Add an image in the primary language.
3. Go to WPML's Media Translation, open the modal to translate the image, and upload a new file.
4. RESULT: WPML shows a red error message "Could not calculate resized image dimensions"

Steps to reproduce (No Error):
1. Make sure that image sizes are NOT disabled on WordPress.
2. Add an image in the primary language.
3. Go to WPML's Media Translation, open the modal to translate the image, and upload a new file.
4. RESULT: WPML works as expected.

Best,
Rafael

Media Settings.png
Error.png
July 3, 2023 at 12:23 pm #13932587

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello Rafael,

thanks for reporting this and providing valuable information.

I was able to reproduce and confirm it, and also as you said the issue is not there with the previous version, WPML Media 2.7.2.

I have now escalated to the 2nd tier to confirm if this is a bug or expected from our side and escalate further if needed.

I will update you soon.

Regards,
Drazen

July 3, 2023 at 2:18 pm #13933729

rafaelC-28

Hello Drazen,

OK. Thanks for the update.

Best,
Rafael

July 4, 2023 at 6:16 am #13937157

Dražen
Supporter

Languages: English (English )

Timezone: Europe/Zagreb (GMT+02:00)

Hello Rafael,

the issue was escalated to our developer's queue and will be fixed in one of the future versions.

In the meantime you can use the next workaround:

- \wp-content\plugins\wpml-media-translation\classes\media-translation\class-wpml-media-attachment-image-update.php

in \WPML_Media_Attachment_Image_Update::resize_thumbnail

Change:

if ( $size['width'] > get_option( 'thumbnail_size_w' ) || $size['height'] > get_option( 'thumbnail_size_h' ) ) {

to

if ( $size['width'] > get_option( 'thumbnail_size_w' ) && get_option('thumbnail_size_w') > 0 || $size['height'] > get_option( 'thumbnail_size_h' ) && get_option( 'thumbnail_size_h' ) > 0 ) {

Regards,
Drazen