Do you have trouble duplicating images and other media between languages? You’re not alone. It’s always been a problem and now it’s solved.
Many themes, especially those designed for photographers and artists, rely heavily on the WordPress Gallery functionality. Until now, you had to upload copies of the same image to all translations, in order for it to appear.
The new WPML Media Translation plugin solves this in a slick way. Without wasting space on the server and without limiting your flexibility, you can now have the same images for all languages, or specific images for each translation.
Background – How WordPress Attachments Work
When you upload a file (image, video, podcast, etc.), WordPress saves it in the uploads directory. It also adds a record to the database that says File X belongs to Post Y. This record is called an attachment.
When you insert the Gallery short tag to a post, WordPress looks for all the attachments that belong to that post and displays them nicely together.
For galleries to display the same images on translated posts, the images on the disk don’t require duplication. We only need to duplicate the attachment records. This is exactly what WPML Media Translation does.
Duplicating Images for Existing Posts
After you enable WPML Media Translation, you’ll see a message offering you to complete the setup. Visit the setup page to automatically copy attachments from posts in the original language to translations.
Note: it’s not a fully symmetrical process. WPML will only copy attachments from the default language to the other languages.
And that’s all. WPML will run through all your site’s content and duplicate all attachments to the translations. Remember that since we’re only duplicating database entries, this doesn’t increase your site’s disk space.
Duplicating Images for New Posts
The post editor will include a new checkbox that says Duplicate uploaded media to translations. When checked, WPML will automatically copy the attachments you add to the default language, to all translations.
The order of operations doesn’t really matter. When there are new attachments, they’re copied. Also, when you create new translations, they get all the attachments from the default language.
There’s a similar checkbox next to the Featured Image, to duplicate it too onto translations.
Choosing Media per Language
This new attachments-duplication makes WordPress media language-aware. You can have the same physical image file associated with posts in different languages.
When you click on the Insert Image button, in the post editor, WordPress will show you images in the post’s language. You’ll find a new language selector to choose images that belong to posts in other languages too.
And, last but not least, when you visit the Media menu, you’ll also see the uploaded media per language.
To switch languages, use the Admin Bar language switcher, available in WPML 2.3.0 and above (for now, you can use the Beta version).
Summary
This plugin adds language switching to all the WordPress media management. It makes attachments language-aware and allows to easily synchronize images between translations.
All you need to do to make this happen is enable the Duplicate uploaded media to translations checkbox in the post editor. The rest happens by itself.
To download, login to your WPML.org account. This new plugin is available for both the Multilingual Blog and Multilingual CMS packages.
Enjoy!
I don’t see WPML Media Translation in downloads section…
Yeah, a little mishap. I’m fixing it and it will be ready for tomorrow morning. Sorry about that. Don’t despair – it’s worth the wait.
It’s there now.
This is some great stuff!
One question I have: is this backward compatible or do I have to recode the entire thing?
Reason I am asking is because for a client’s website I went out of my way to make it possible for them to upload images in the default language and not having to duplicate anything.
I used the method described on http://wpml.org/2009/09/creating-a-multilingual-product-catalog/.
If you already have a solution for existing sites, I don’t see a good reason to change. For new sites, you can rely on the new Media Translation plugin to do the work for you. It gives the extra flexibility of being able to automatically duplicate everything, or have some different images per language.
Nice work there !
Been requesting / waiting for this awesome feature since a while 😀 (remenber my tweet / forum post about that ^^)
This is one of the most frequently requested features and I’m glad we finally managed to get it coded.
This is Awesome!
I was just about to start a tedious work of reuploading a few hundred images to translated articles. Now I can do it with one click.
You made my day 😉
Yes! Yes! Yes!
Thank you so much!
After install the plugin Media, upload.php page (Media Library) is all white.
Better use our forum for technical support. When you do this, make sure you include details about your site and any PHP errors in the PHP log file.
Hello,
is it possible to change image Alt tag for the same photo displaied in posts/pages different language versions ?
Yes, each language will have its attachments and you can embed images with any ALT attributes that you like.
I have already re-uploaded photos of my products to the translated products. I’m not sure if the photos are the same for both so this plugin would be very useful to ensure they are the same. I noticed the note in the plugin which says, “Note: attachments are only duplicated if the translated content has no existing attachments.”
Does this mean I need to go and delete the photos from the translation first?
Thanks
Dan
You may delete the duplicate photos that you’ve uploaded before. Then, the Media Translation plugin will do it for you.
Please be careful with this. Test on one post, see that you like how it works and then do on other posts.
Understood. Thanks
Feature request: be able to “share” an image for all translation – there a lots of cases where you do not want to localize images and with current implementation you get big problems if you want to update one image later, you have to do it for all languages.
In the post edit page, there’s a checkbox to duplicate images onto translations. This does exactly what you’re requesting.
When this checkbox is selected, the Media Translation plugin will automatically create attachments for new images. This happens when you save the post in the original language, after uploading new images.
Hi Amir,
Did you happen to notice my question above?
Hi Amir,
I just purchased WPML for my multilingual blog, but I am not sure whether or not it will work or what should I do to make it work, provided that I run 3 domains, one in English, one in Italian and one in German (so basically so far, I translate 3 sites at the same time, which look identical but are instead on three different domains). I purchased and downloaded it and installed it only on the Italian site, because i want to get German transaltions too, which i would then copy paste to the other German domain…or how should I make it more simple?
You can configure WPML to put different languages in domains (in WPML->Languages).
Start with a simpler configuration (like languages in directories), migrate the existing content from the other sites to the new multilingual site and then switch to using a single site with WPML and different languages in domains. This FAQ explains how to setup Apache and your DNS:
http://wpml.org/faq/server-setting-for-languages-in-directories/
If you need more help with this, please use the forum:
http://forum.wpml.org
Hi Amir,
the Media translation is great!
Any plans to have this option in the “Translation Editor”?!
Is it now available only in the “normal” post?
It would help us a lot to have all features in the translation editor!
WPML should automatically create the duplicates for images when you save translations from the translation editor.
When you select in the original to duplicate attachments, the translated posts (through WPML’s translation editor) should have the same attachments too. Isn’t this working for you?
Thanks amir, no it is not.
Reason: it is a special Woo Theme using a gallery funktion.
It works in the normal post but not in the translation editor.
Is there a way to simply specify the language of an existing media item and then specify which file corresponds to its French translation? I thought this would be a new option available in the media library when you edit a picture (ie: language of image: “French”) the same way this sort of functionality works for categories, posts, etc.
The reason I ask is because we upload media that is never attached to posts but used in other places with plugins that simply pull those images and display them based on some criteria. (In other words, they aren’t attachments, and never will be.) How do we simply specify the language of those images and their associated translated content (which is already uploaded)?
Thanks,
Good idea !
And it will be really useful for the Revolution and Layer Sliders !
The language setting is more implicit. WPML will associate the media with the language of the post that you upload to.
I see you wrote this in 2011.
Is it still like that today ?
Yes
Hi there!
Great plugin…
Still, NextGen just released new version and your plugin does not fit with it… Come one, guys, 3,561,296 users need your help to improve it!!!
And don’t tell me Alex should work with it… It’s all open source and you can manage for sure!!!
It will be a GREAT improvement to the plugin… Any idea of any date?
jesus
We tried our best to work with the author of NextGen and it seems that he’s too busy for that. If it’s important to you, create a thread about it in NGG support forum. We’re always happy to work with other authors, and we have the resources for that.
I work with WPML for quite a while now. I don’t want to loose much words about it. I just want to say that I think WPML is a great, brilliant and ingenious piece of work.
Thank you.
artes
I was looking for a way to store multiple translations for the description and caption of an image. Is there any way to do that with this plugin?
Yes. Once the Attachment entries are duplicated in the DB, you can edit them and enter the correct description per language. Use the Admin bar language switcher to move from one language to the other, when you’re in the Media admin screen.
I’m looking for a way to have an image in the media library that is not attached to any page / post and with a different description and caption in each language. Is it possible? Thanks
WPML doesn’t add the language attributes to the attachments, but to the posts that include these attachments. We did that, so that we don’t have to hook to each and every possible way that people can add attachments. If your images don’t have to belong to any post, I suggest that you create a dummy post and connect them to it – just so that you have some language reference.
Thanks Amir. The question was regarding a plugin that populates a slider based on some specific images “tagged” in the media library and not attached to any posts.
I believe creating a dummy post every time the plugin is installed just to allow multilingual image descriptions is not the best way to go. Basically, because this is not friendly for the regular WordPress user.
What would you suggest to the developer of the plugin? Basically, what the plugin does is add an option to those images uploaded to the media library from WP-Admin > Media. This option allow users to select if the uploaded image is part of the slider. The plugin fuctionality is that simple and easy to use. Any way to make it WPML compatible?
Thank you very much
Yes, that sound’s great. I was searching for this functionality. If I want to delete an attachent again, do I have to delete it for every language or does this happen automatically, too?
When you’re in the Media page, you can choose ‘all languages’ and then delete all at once.
If I create an English home page and use the “attached gallery” for a slideshow, will the images be synced. I realize that I can automatically duplicate the gallery to the other translations. But, when my client deleted an image in the english translation the images were not deleted for the other translations.
We don’t delete images automatically. We thought about it, but the risk of accidentally deleting data appeared greater than the benefit of this auto-sync.
Excellent plugin! However, this feature does not seem to copy custom fields associated with the attachment. Looks like function create_duplicate_attachment needs to be expanded to go through all custom fields as well. Am I missing something?
That’s possible. Normally, attachment items don’t have custom fields, so we didn’t consider it. Are you adding these custom fields using API calls, or somehow via the WordPress GUI?
We are adding them through custom functions in our template utilizing:
add_filter( ‘attachment_fields_to_edit’, ‘ADD_FIELDS_FUNCTION’, 100, 2 );
add_filter( ‘attachment_fields_to_save’, ‘SAVE_FIELDS_FUNCTION’, 100, 2 );
sorry, but i don’t see this plugnin my section account
thank you
It’s under ‘Downloads’.
Hi there!
I’m looking into purchasing this for my client’s English/French website.
One question that I’m not sure has been asked is if you have an image that includes type (in English), will you be able to upload the same image translated to French for the French side of the site?
Thanks so much!
Yes. Images can be different on different languages. If the image is part of a post or page, you’ll just insert a different image there. If it’s part of the theme, you can use a bit of PHP and check WPML’s language constant to display the correct image per language.
Good to know. Thanks!
What about images that have text in them? I.e. text in different languages.
Images with text are just like any other image. You can upload different images for different languages.
Hi, does this plugin work from WP 3.5 on?
I’ve installed it and although the images in different languages are shown in the Library Media, from a translated page “media modal” inserting images it doesnt find any image.
Yes, works fine on WordPress 3.5.1. If things are not working completely well for you, can you please open a thread about it in our support forum? Explain everything and give links and/or screenshots that show what you’re seeing.
I just installed it on a WordPress 3.5.1, all plugins updated.
I cannot query my attachments in the secondary language (English). Even though in the Media screen they appear in English, all queries fail to return results unless I do suppress_filters=true.
For example, this SQL returns no results:
SELECT wp_posts.* FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) JOIN wp_icl_translations t ON wp_posts.ID = t.element_id AND t.element_type = ‘post_attachment’ JOIN wp_icl_languages l ON t.language_code=l.code AND l.active=1 JOIN wp_term_relationships AS trel ON ( wp_posts.ID = trel.object_id ) JOIN wp_term_taxonomy ON ( trel.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id AND wp_term_taxonomy.taxonomy = ‘type’ ) LEFT JOIN wp_terms ON ( wp_term_taxonomy.term_id = wp_terms.term_id ) WHERE 1=1 AND ( wp_term_relationships.term_taxonomy_id IN (241) AND wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (377,378,379,380,381,382,383,384,385,386,387,388,389,390,391,392,393,394,395,396,397,398,401,402,403,404,405) ) ) AND wp_posts.post_type = ‘attachment’ AND (wp_posts.post_status = ‘inherit’) AND t.language_code=’en’ GROUP BY wp_posts.ID ORDER BY wp_terms.slug ASC,wp_posts.post_title ASC
But if I remove the “AND t.language_code=’en'” it returns what I need, even though all those attachments are attached to an English post.
I have all the plugins updated, and there’s no way to put different featured images for each language. Where is a tutorial that shows up how to do it step by step???
I upload a featured image in a english page, and it is always the same featured image in the spanish version of that page, instead I choose a different image on the spanish featured version… always is in english. I am a little bit dissapointed with the support of this plugin, really.
Regards
Do you have the checkbox to synchronize the featured images selected? If so, WPML will set the same featured image for posts in all languages. That checkbox is found in the post edit screen.