The Media Translation module manages media attachments like images so that you can re-use the same media files on translated posts while still translating their title and related fields.
When you translate content that includes attachments, such as images, audio or video files, you might want to use the exact same media files in different languages. The Media Translation module lets you easily reuse the same files contained in your content, in different languages.
This is a sample page, showing a gallery of the uploaded images (from a trip to Greece, which is highly recommended).
Our goal is to display the same image gallery, with translated captions, in the translated page.
First, be sure to install WPML Media (part of both Multilingual Blog and Multilingual CMS packages). You can get the plugin on your Account’s Download page. Once installed, there is nothing to configure.
Copying and Translating Attachments
Once you’ve activated WPML Media, you will see new Media Attachment controls in post-edit screens.
Select the check-boxes before you add the translation. WPML Media can create attachments for the translated content and also set the featured image.
Next, we can edit the translated content. Click on the Add Media button to open the media screen for that page. Select the Uploaded to this page option to show only media items that belong to this page.
These are the same images that you uploaded to the original page. WPML doesn’t duplicate the image files. It only connects them to the translated content, so that you can display galleries with the same images in translated content.
You can edit the image captions and description. This will only change the texts for the images that appear on the translated content.
Here is how the translate page looks like, with a gallery showing the images with their translated captions.
As you can see, the end results are what we set out to do. We’ve translated the ‘Trip to Greece’ page and it displays the same images in both English and Spanish. We’ve edited the captions, so that everything displays in the correct language.
Multilingual WordPress Media Library
WPML Media also enhances the WordPress Media Library.
When you switch languages, using the admin-bar language selector, you will see only attachments that belong to content in that language.
This gives you convenient central administration for media items, per language. You will be able to translate captions and description texts for everything in your site, no matter what content it belongs to. Again, the same media files are used for all attachments. We are translating the database entries per language.
Duplicating Attachments in Existing Content
If you already have a lot of content and just now added the WPML Media module, you can duplicate the attachments information without having to go through each page at a time.
Go to the WPML -> Media Translation page.
The first section of this page includes batch processing options. Normally, you need to use them after you just installed Media Translation, or if you are using another plugin which adds media items, bypassing the normal WordPress content editor.
The options in this section are:
- Set language information for existing media – Before you install the Media Translation addon, media items don’t have a language. This will set the default language to existing media items.
- Translate existing media in all languages – This will duplicate the media library to all languages, so that you see existing media items when you create translated content.
- Duplicate existing media for translated content – This will create copies of the attachment entries in the database, for all existing media. This way, you can display galleries of the same media files in translated content.
- Duplicate the featured image for translated content – This will set the same image, as featured, for all translated content.
Once you run this batch processing, your media items will have language information and you will have the same media items available for all translations. There is no need to revisit this admin screen. WPML Media Translation will automatically add language information to new media and can synchronize media entries for translations.
The second section of the admin screen, “how to handle media for new content”, lets you choose if new media is automatically synchronized to all languages. By default, all options are selected. Unless you need completely different media items for different languages, you should leave these options enabled.
The Difference Between Attachments and Files
Attachments are entries in the database. Each attachment is a single row, telling WordPress that a file belongs to a post.
Files are the media items themselves, which are stored on the server’s drive.
When you duplicate attachments, you only create new DB entries for the same file. So, if you have an uploaded image and you are duplicating the attachment to seven languages, you are only creating seven new DB entries for the same file. The file itself is not copied or duplicated.
These attachment entries in the database associate the file with posts and pages. When you display media using the gallery shortcode or with plugins that rely on attachment data, you will display the media files that belong to that content. WPML’s Media Translation allows you to associate one file with several pages in different languages.