Skip Navigation

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 topic contains 3 replies, has 2 voices.

Last updated by Andreas W. 11 months ago.

Assigned support staff: Andreas W..

Author Posts
September 12, 2021 at 3:55 am #9570239

Santiago

Hello there,

Please, can you help me to understand how to delete all the media translations.
I have many languages and many images.

When "Post Types Translation - Media (attachment)" is "Translatable"
I can see my images on all my languages.
Images are not duplicated on the upload folder but are duplicated on the database.
I need some way to delete all the translations when I delete any image from the main language.

I already try the "When deleting a post, delete translations as well" and don't do the job.

Also try your:
https://wpml.org/forums/topic/script-to-delete-all-media-translations-please/
But I can't make works.
Do you test this code and it's working?
I should add inside the function.php?

By the way, looks like many people needs the same in the pass.
Any idea how to simple do?
Should be on the settings.

Thank you.-

September 12, 2021 at 1:38 pm #9571361

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

First, please take a reliable backup of your site and database.

Then, you could go to the media library and switch the language inside the top admin bar.

Now, on the top-left chose the icon to select "View as list". Now, mark your media elements and delete them in bulk.

In case you handle quite many duplicated images, we could try the following solution, but I would suggest to test this on Staging first:
https://wpml.org/forums/topic/script-to-delete-all-media-translations-please/#post-2018583

Best regards
Andreas

September 13, 2021 at 12:55 am #9572827

Santiago

Hello Andreas and thank you for your update.
1.- I can't do manually, we are talking about more than 100K imagenes.
2.- I say the link you share and I also share, but can you detail more about the way to use that? should be added on the function.php or somewhere else? About that code, don't look like an official solution, is that correct?
I will wait for your update.
Thank you in advance.-

September 14, 2021 at 9:23 pm #9587275

Andreas W.
Supporter

Languages: English (English ) German (Deutsch )

Timezone: America/Lima (GMT-05:00)

Hello,

Exaclty, this code is a kind of workaround.

WPML will not remove any translated content when deactivating a language or even when deinstalling or even resetting the WPML plugin.

The reset action does not delete translated images, translated posts, and translated taxonomies. It only affects the translation and language information that WPML associates with each content type inside the database.

All pages, posts, taxonomies, and media will need to be removed manually.

Now, we even could run some custom MySQL queries on your database and simply delete any media attachments inside the table wp_posts that are assigned to a different language than the ones you desire to use.

The same we might need to do on the wp_postmeta and the icl_translations tables as well.

Anyhow, as in the following ticket suggested by another user, the recommended way is using the WordPress backend for removing the media content, as each media element that you upload to WordPress is connected to various tables, and running an incomplete query could lead to unexpected DB entries that were missing or forgotten to get removed while running the queries.

https://wpml.org/forums/topic/remove-multilingual-form-woocommerce-completely/#post-526208

Best regards
Andreas

The topic ‘[Closed] Delete all media translations’ is closed to new replies.