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.

This thread is resolved. Here is a description of the problem and solution.

Problem:
How can I copy the Envira tags to the translated media?

Solution:
Go to file \plugins\envira-tags\includes\global\shortcode.php and search for this line:

$terms = wp_get_object_terms( $id, $taxonomy );[php]

and replace it with

[php]$terms = wp_get_object_terms( apply_filters( 'wpml_object_id', $id, 'attachment', true ), $taxonomy );

Then save the changes. Now, as long as you have checked the box to duplicate media in WPML -> Settings, when you add a new image and assign it an Envira tag, the image will duplicate to the secondary language and will have the tag.

Now, this does not resolve the issue for images that have been already uploaded in my test site, but it does resolve it for images that will be updated going forward.

This topic contains 18 replies, has 2 voices.

Last updated by miroslavV-3 1 year ago.

Assigned support staff: Lauren.

Author Posts
September 19, 2018 at 6:30 pm #2749784

miroslavV-3

Hi,

We are using Envira Gallery plugin to tag the images and then show galleries on the website based on these tags. We do not translate Envira tags because tag names are never displayed on the frontend. Currently, when I upload an image to the WordPress media gallery, I have to add Envira tags to the image in English, then switch to Spanish and add the same tags in Spanish.

Is there a way to make the tags sync between the two languages? I mean, for example, I would like add tag "website" on English and have this tag automatically picked by Spanish as well, without having to do the same work twice.

Thank you.

September 20, 2018 at 7:54 pm #2753206

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thank you for contacting WPML support. I'll be happy to help you with this.

Please go to WPML -> Settings and in the Custom Fields section, click "Show system fields". Then, check to see if you can find this tag field associated with the Envira gallery and set it to copy.

Then, save the original post and update the translation, and the tags should then be copied.

Please let me know if you need any further assistance and I will be happy to help.

September 20, 2018 at 9:38 pm #2753348

miroslavV-3

Hi,

Thank you for the answer.
When i go to WPML -> Settings, i don't see custom fields or system fields mentioned at all.

However, on that page, in the 'Taxonomies Translation' section there are 'Envira tags' with 3 available options:
-Translatable - only show translated items
-Translatable - use translation if available or fallback to default language
-Not translatable (currently selected)

However, there's no option "copy"

September 21, 2018 at 12:29 pm #2755172

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.

Privacy and Security Policy

We have strict policies regarding privacy and access to your information. Please see:
https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

**IMPORTANT**

- Please make a backup of site files and database before providing us access.

- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link

September 21, 2018 at 2:54 pm #2755615

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thanks for sending credentials. In the taxonomies section, I see Envira tags. If you try setting this to Translatable/Fallback to default, does this resolve the issue? If not, what happens if you set it to translatable but then add the translation, even if you copy the translation from the original?

September 21, 2018 at 4:22 pm #2755976

miroslavV-3

Hi,

I've set Envira tags to "Translatable - use translation if available or fallback to default language", then I've uploaded a new image to the WordPress media library (while having it in English) and added Envira tag "website". The image successfully appears on the English front-end page but not on the Spanish. Then I switched WordPress media gallery to Spanish, edited the same image, and saw that Envira Tags field is empty in Spanish. So I tagged the image "website" and now it appears on Spanish front-end page. Additionally an Envira tag "website-es" got created automatically after this. So it didn't solve the issue...

Then I tried your second advice - setting it "translatable". I've uploaded a new image again and added tags on the English image. The image appears on the English front-end page but not on the Spanish. I've switched media library to Spanish, added tags to the image on the Spanish media library (because the field was empty as the other time) but even after this the image doesn't appear on the Spanish front-end page. (the other difference from the first case is that Envira tag "website-es" didn't got created automatically).

By the way, I've already contacted Envira few days ago, hoping that they can help but they referred me to you.

Thanks

September 21, 2018 at 5:03 pm #2756047

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Can you please tell me the URL for the page you are testing to see if the image tagged "website" shows up? Here is what I did. I went to WPML -> Taxonomy Translations and selected Envira Tags. I can see that no tags have been translated. I went to the tag "Website" and copied it to the secondary language.

Then, I went to Envira Galleries -> Tags and clicked on Spanish to show the translated tags (only website appears). I then click quick edit and change the slug from website-es to just website.

Now, I would like to see if this resolves the issue, but I"m not sure what page the images that are tagged "website" are supposed to appear on.

September 21, 2018 at 5:51 pm #2756274

miroslavV-3

Hi Lauren,

Thank you.

The thing is that we will be creating a lot of new tags while uploading new images, directly by adding a new, sometimes not yet existing tags to the images. Going to "Envira Tags" and copying all to the new languages each time would be just very time consuming... Therefore I'm looking for a solution as much simple as possible, where I would be able to add/edit tags to the images through the WordPress media gallery just in one language, and have the same tags be applied on the Spanish, without having a) to manually create translations of each tag or b) without having to add tags for every image twice (once for each language).

Here is the English page that shows all images with the tag "website":
hidden link
And here is the Spanish version of the same:
hidden link

September 21, 2018 at 6:43 pm #2756304

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I found that if I set the Envira Galleries to "Translatable", the images show up on the translated page: hidden link. I set the Envira tag to Translatable/Fallback to default. Do these settings resolve the issue for you?

September 24, 2018 at 9:02 pm #2761818

miroslavV-3

I've set Envira Gallery to Translatable/Fallback to default. Tags are set to not translatable.

I've tested it with adding a new tag called "other". The image appeared on the English page:
hidden link
But not on the Spanish:
hidden link

It appeared on the Spanish page only when I've manually switched WordPress Media Library language and added the tag "other" to the empty field.

So this Envira tag field is still not being copied throughout languages... Maybe I need WPML Media plugin?

September 25, 2018 at 1:59 pm #2764140

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Let's try duplicating the gallery and see if this resolves the issue. I notice that the WPML Duplicate option is not displaying on your gallery, and I have seen this happen as a conflict with some of the other duplicate plugins that you have activated. Please temporarily deactivate those plugins and then open up the Envira Gallery. Then check the box to duplicate and click "Duplicate". This should copy the images and 'hopefully' the tags as well.

Please let me know the results.

September 26, 2018 at 1:22 pm #2767473

miroslavV-3

Hi Lauren,

I've removed the two Duplicate plugins but no option to duplicate Envira Gallery appears. I'm not sure if that helps but the gallery named "Envira Dynamic Gallery" is not a real gallery, it's more like a global settings page for all the dynamic galleries on the website.

I've also tried to create a translation of that gallery but it doesn't really help, so i deleted it.

Maybe the issue is with media translation settings? I've noticed that if i delete an image, it get's deleted only in that particular language and stays on another language. It would mean that once uploaded, the image seems to act independently on each language (probably including Envira tags for that image). Not sure if this might be related to my issue.

Thank you.

September 26, 2018 at 8:26 pm #2768691

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

I need to run further tests. To best troubleshoot the issue, please make a snapshot of your site using the Duplicator plugin: https://wordpress.org/plugins/duplicator/. This will allow me to try and duplicate the error so that I can run further tests without interrupting your live site.

Once the snapshot is complete, either upload the snapshot ZIP file and the installer.php file to a file sharing service such as Dropbox (and share the link in your reply) or right click the Duplicator links in your wp-admin and paste in your reply.

Please note: It is important to reduce the size of the package so please exclude some paths like /cache or /uploads and also exclude archives and media files.

I will also need the username and password of an account that was created BEFORE creating the duplicator package.

I will enable the next reply to be private so only you and I have access to it!

September 27, 2018 at 6:14 pm #2771535

Lauren
Supporter

Languages: English (English )

Timezone: America/New_York (GMT-04:00)

Thanks for the Duplicator files. I set up a copy of your site. After digging around a bit, I found that our developers are currently working on an issue with translating the tags. In their documentation, I found this resolved the issue of copying the default language tags to the secondary language:

Then this is how the gallery can be translated.
Go to file \plugins\envira-tags\includes\global\shortcode.php and search for this line:

$terms = wp_get_object_terms( $id, $taxonomy );[php]

and replace it with 

[php]$terms = wp_get_object_terms( apply_filters( 'wpml_object_id', $id, 'attachment', true ), $taxonomy );

Then save the changes. Now, as long as you have checked the box to duplicate media in WPML -> Settings, when you add a new image and assign it an Envira tag, the image will duplicate to the secondary language and will have the tag.

Now, this does not resolve the issue for images that have been already uploaded in my test site, but it does resolve it for images that will be updated going forward. So you will likely need to manually add the tags for your images in the secondary language that have already been uploaded.

Please let me know if you need any further assistance and I will be happy to help.

September 27, 2018 at 10:04 pm #2771924

miroslavV-3

Thanks for help! However, this doesn't seem to solve anything.

I've amended the php code as per your instructions. Then I've uploaded a new image to the WordPress media library (while having it in main language) and I've added Envira tag "other" to it. This made the image appear in the gallery only on the English page. I still had to switch backend to Spanish and the add the tag one more time, only then image appeared on Spanish gallery page.