Pular a navegação
60

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.

Admin menu for WPML Media Translation

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.

Checkbox for controlling attachments duplication

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.

Language selector for media insert

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).

Language switcher in the Media screen

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!