This thread is resolved. Here is a description of the problem and solution.
Problem:
Converted pictures using EWWW image optimizer to png will get lost in second language
Solution:
Workaround from compsupp-6701
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: Compatibility
This topic contains 13 replies, has 2 voices.
Last updated by Stéphane 1 year, 8 months ago.
Assisted by: Ilyes.
Author | Posts |
---|---|
March 22, 2023 at 11:19 pm #13309567 | |
Stéphane |
Tell us what you are trying to do? Is there any documentation that you are following? Important to know: The problem: What is the link to your site? |
March 23, 2023 at 9:39 am #13313309 | |
Ilyes Supporter
Languages: English (English ) French (Français ) Timezone: Pacific/Easter (GMT-05:00) |
Hello Stéphane, Both your theme “Woodmart” and plugin “Ewww Image Optimizer” are indeed listed as compatible with WPML. In order to see if this issue is happening because of the configuration of your staging site, or just the combination of the EWWW Image Optimizer & WPML we need to isolate the issue. I’ve created a sandbox here: hidden link I’ve already configured WPML in 2 languages. Please do the following: Open the Sandbox link mentioned above Please note that we only need the theme/plugin and the related functionality, you don’t need to setup a entire website or clone your existing site. https://wpml.org/faq/how-to-reproduce-issues-and-share-them-with-wpml-support/ Let me know when it is done. Best regards, |
March 23, 2023 at 1:41 pm #13315697 | |
Stéphane |
Hi Ilyes, I followed your instructions, and here is exactly what I did: Result: Here is some screenshots to show what I'm talking about. Thanks in advance for helping with that issue. |
March 24, 2023 at 2:07 pm #13323933 | |
Ilyes Supporter
Languages: English (English ) French (Français ) Timezone: Pacific/Easter (GMT-05:00) |
Hello, Thank you for your patience, we had to test multiple scenarios, I did 4 different environments with one specific picture (hidden link) and here are the results we got : 1- With Woocommerce and WPML : Uploaded .png product > translated it > Images are visible but we could see some traces of the .png link under the source code : hidden link 2- Without Woocommerce and with WPML : Created a new page with a .png picture > translated it > image is visible but again some traces of the .png link is seen under the source code : hidden link 3- With default Theme and WPML : Same result as previously 4- Only EWWW is active (no WPML, no WooCommerce and default theme): Created a new page with a .png picture > translated it > image is visible but again some traces of the .png link is seen under the source code : hidden link Things to keep in mind: I Tried these cases with different pictures, and got different results depending on the picture, sometimes EWWW just ignored the conversation (check this post : hidden link ) and some other times the .png trace didn’t exist (check this page: hidden link) Conclusion: What can you do : - You can try with several different pictures then you can see different the results and contact EWWW, they might be aware of this issue as suggested under their website here : hidden link - They explicitly suggested that in some cases, it is more difficult to ensure that the database is updated with the new filename(s). - And if you can provide us with a clear step by step to follow, to reproduce the issue as we have diverse results. Please do not hesitate to contact us further if needed, Thank you, |
March 24, 2023 at 4:18 pm #13325243 | |
Stéphane |
Hi, Thanks for those tests, but I think they don't reflect our reality, because we are using EWWW on already existing and translated products. So, to really see the problem, here is what you should do: 1- Deactivate EWWW (because it as to be disabled when you'll create the product, and translate it too) Another way to confirm the problem is by testing the page with GT Metrix: hidden link (FYI, I did that test with Twenty Twenty theme, then we can see that the problem is between WPML & EWWW, and had nothing to do with Woodmart Theme) In conclusion, it seems to be a dysfunction between WPML and EWWW. Thanks to test it by yourself, and I'm sure you'll get the same result as me. Then, I think it would be more logical that you talk with EWWW, as WPML recommends EWWW, and as EWWW told me it would work. Thanks in advance. |
March 27, 2023 at 2:11 pm #13339639 | |
Ilyes Supporter
Languages: English (English ) French (Français ) Timezone: Pacific/Easter (GMT-05:00) |
Hello there, Thank you for the details, After further testing, I have escalated it to our developers. We will be in contact with EWWW authors, but in the meantime, it may be useful if you talk to them directly as a client, they may already be aware of this issue. I will update you once I receive feedback, also please feel free to check with me later on to see the status and I will be happy to let you know the status of this fix. Your patience is appreciated and have a wonderful day, Best regards, |
March 27, 2023 at 9:57 pm #13343377 | |
Stéphane |
Hi Ilyes, Thanks for letting me know what's happening ... Concerning EWWW, I already had a long conversation with their support prior to trying their plugin, and they assured me that it was working for what I needed to do. So I think it's better to let your devs talk with their devs, and see if they find a way to make it work, which I hope considering the time energy I've put in that plugin. Thanks in advance and I'll be waiting for news from you. |
March 28, 2023 at 12:15 pm #13349093 | |
Ilyes Supporter
Languages: English (English ) French (Français ) Timezone: Pacific/Easter (GMT-05:00) |
Hi, Thank you for sharing these details and for your patience, I’m keeping an eye on the status of your ticket, I will update you once I receive any feedback, Your time and energy are appreciated, Thank you |
April 11, 2023 at 3:06 pm #13447685 | |
Stéphane |
Hi Ilyes, any news from the Compatibility team ? Thanks |
April 11, 2023 at 3:45 pm #13447961 | |
Ilyes Supporter
Languages: English (English ) French (Français ) Timezone: Pacific/Easter (GMT-05:00) |
Hello, Thank you for your patience, Actually, yes, I have recently received a solution to your issue. It is related with the _wp_attachment_metadata post meta, we can use the wp_get_attachment_metadata to change the file format on front-end. For this, please add the following code to your theme's functions.php file: // WPML Workaround for compsupp-6701 function wpml_compsupp6701_fix_jpg_image_format( $data, $attachment_id ) { // Runs only if WPML is enabled if ( class_exists('Sitepress') ) { $image_url = wp_get_attachment_url( $attachment_id ); $image_extension = strtolower( pathinfo( $image_url, PATHINFO_EXTENSION ) ); $attachment_metadata_extension = strtolower( pathinfo( $data['file'], PATHINFO_EXTENSION ) ); if ( $image_extension != $attachment_metadata_extension && $attachment_metadata_extension === 'png' ) { // Replace the extension with "jpg" in the file name $data['file'] = preg_replace( '/\.png$/i', '.jpg', $data['file'] ); // Update the metadata for each image size foreach ( $data['sizes'] as &$size ) { $size['file'] = preg_replace( '/\.png$/i', '.jpg', $size['file'] ); } } } return $data; } add_filter( 'wp_get_attachment_metadata', 'wpml_compsupp6701_fix_jpg_image_format', 10, 2 ); This should fix the 404 errors on front-end and load the correct image format. We will be also contacting the author of EWWW image optimizer plugin for a proper update. Thank you again for your patience, Best, |
April 11, 2023 at 3:55 pm #13448005 | |
Stéphane |
Great news, thanks ! Just to be sure to understand how this code should make it work: Do I need to re-run EWWW Optimizer to make the images appear, or I should just add that code and everything will be fine ? Thanks in advance for this details. |
April 11, 2023 at 4:20 pm #13448255 | |
Stéphane |
Forget my last message, I added the code and verified that it works without re-running EWWW, as the code just replaces the image extensions ! Thanks for your help. |
April 11, 2023 at 4:38 pm #13448703 | |
Ilyes Supporter
Languages: English (English ) French (Français ) Timezone: Pacific/Easter (GMT-05:00) |
Hello, Thanks for the feedback, I'm glad it worked for you, you can then set this ticket as resolved. Have a great day, |