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: Documentation request
This topic contains 5 replies, has 2 voices.
Last updated by Prosenjit Barman 1 year, 7 months ago.
Assisted by: Prosenjit Barman.
Author | Posts |
---|---|
November 8, 2023 at 8:24 am #14753477 | |
xavierC-7 |
I am using a wp gallery field to return a list of images, At some point in my theme development, the image sizes were as follow : I used regenerate thumbnails to regenerate all the image sizes, and chose "delete unused image sizes" and also "do not skip already existing image sizes" to be sure of a clean slate. This is the code that returns my gallery images in a foreach statement : Works well in the main language (french) and returns the image with 440 width and 535 height. in the secondary language this is what is returned : So the image is broken and returns a 404, I tried deleting the images from the gallery field of the main language and putting them in again, but it does not work. I tried deleting the translation and translating again, but it still returns outdated data, why ? |
November 8, 2023 at 11:55 am #14756125 | |
xavierC-7 |
I continued my investigations, and I can see that in the media gallery, the same image has different ID in different language. |
November 8, 2023 at 12:11 pm #14756221 | |
xavierC-7 |
Ok so I still continued my investigations and find out that if I regenerate thumbnails for the image WHILE i'm in the secondary language in the dashboard, it fixes the image size. I'll keep you updated. But I still have a question, is it normal that even if I don't use media translation, my images don't have the same ID when I change language in the media library? |
November 9, 2023 at 9:54 am #14764193 | |
Prosenjit Barman WPML Supporter since 03/2023
Languages: English (English ) Timezone: Asia/Dhaka (GMT+06:00) |
Hello There, I understand the issue and it's great to hear that you have already identified a solution for it! In response to your question- When Media Translation and Duplication has activated under "WPML > Settings → Media Translation", WPML indeed generates a new database entry for each translated image. As a result, a new ID gets assigned to the translated media item. The translated Media gets generated after translating the post or page that contains an image. Please check this documentation for more information: https://wpml.org/documentation/getting-started-guide/media-translation/#id5 If you don't want the WPML to create a new entry with a unique ID, you can disable the options under "WPML > Settings → Media Translation". By doing so, the image will not be copied to the translated page/post. You'll need to manually add an image for each translation. I hope this explanation is clear to you. If you need further assistance, feel free to let me know. I will be happy to help. Best regards, |
November 9, 2023 at 11:30 am #14765549 | |
xavierC-7 |
Ok thank you for your answer, indeed regenerating image sizes in both languages did the trick. Is there a plugin you recommend that would regenerate and update the meta_data of all "language wise" images at once? It wastes ressources because the physical copies of images are regenerated twice. |
November 10, 2023 at 4:43 am #14772217 | |
Prosenjit Barman WPML Supporter since 03/2023
Languages: English (English ) Timezone: Asia/Dhaka (GMT+06:00) |
Hello There, I'm glad to hear that regenerating image sizes for both languages resolved the issue, although I understand the process is quite time-consuming with a large number of high-resolution images. Currently, I can't recall any specific plugin that can generate metadata for all images at once. However, I can share a script that could be used to generate metadata for all the images in the media library. This script would automate the process, potentially saving you time and resources by handling the task in one go. You can find the script here: hidden link The process of using the script is described in the readme file. Please try accordingly and hopefully, it will help to generate Metadata for all the images in the media library. Before proceeding, make sure to take a full backup of the site and database. Please let me know if that helps or if you need further assistance in this matter. I will be happy to help. Best regards, |
November 10, 2023 at 9:05 am #14773627 | |
xavierC-7 |
Thank you, you really provide great support. |