Skip to content Skip to sidebar

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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Tagged: 

This topic contains 53 replies, has 0 voices.

Last updated by Otto 3 months, 3 weeks ago.

Assisted by: Otto.

Author Posts
September 16, 2025 at 11:05 am #17405852

andraZD

Hi Otto. I have been extremely busy for the past few weeks, so I am replying with a delay. I will try to prepare the DB as soon as I have some more time because I do not want to do something in a hurry and mess it up even further 🙂

September 17, 2025 at 1:20 pm #17409891

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello,

Sure, thanks for the heads-up.

The ticket will remain open for two weeks without any activity. If you need more time, just drop a message here.

Best Regards,
Otto

September 23, 2025 at 6:52 pm #17426910

andraZD

Hi Otto, I would probably need youe email to add you/share the folder where I would put the files? The sizes are too large to use anything else I would say.

September 29, 2025 at 11:50 am #17440803

andraZD

Hi, I will try to create a database dump today/tomorrow if I get a chance and see what service I can use to send it, since it is quite a large thing.

September 29, 2025 at 1:43 pm #17441333

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello,

Thanks for the heads-up.

Best Regards,
Otto

October 6, 2025 at 3:38 pm #17461392

andraZD

Hi Otto, I have just sent you the acces to your email.
With a bit of a delay because I have too much work lately to focus on everything.

Best regards,
Andraz

October 7, 2025 at 12:38 pm #17463787

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello Andraz,

I got the files and managed to deploy your site in my local development environment.

I am still checking the issue. I'll get back to you as soon as possible.

Best Regards,
Otto

October 7, 2025 at 1:30 pm #17464004

andraZD

Hello Otto,

thanks. If you find any solution I will send it to the hosting company and let them run a querry. I am not skilled enough to dare to do it myself on this field 🙂

I am currently out of office for the next 10 days so there is no rush. I might pop a message just to keep the ticket open if needed.

Thanks,
Andraz

October 8, 2025 at 3:53 pm #17467924

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello Andraz,

I tried to clean the duplicated images safely, but I couldn't. I escalated the issue to our second tier support. I'll get back to you as soon as I have news about the issue.

Best Regards,
Otto

October 12, 2025 at 7:06 am #17477040

andraZD

OK, thanks. I hope there is a way to delete them because they are causing quite a lot of issues on souch large page.

October 13, 2025 at 8:45 am #17478730

Christopher Amirian
WPML Supporter since 07/2020

Languages: English (English )

Timezone: Asia/Yerevan (GMT+04:00)

Hi,

This is christopher checking with this issue. We have a question from the second-tier support.

There is a huge improvement on how Media Translation works on WPML version 4.8.2.

I wonder if you tested the same thing with the new version?

- IMPORTANT STEP! Create a backup of your website. Or better approach will be to test this on a copy/staging version of the website to avoid any disruption of a live website.
- Go to "WordPress Dashboard > Plugins > Add new > Commercial (tab)".
- Click the "Check for Updates" button.
- Update WPML and its addons there.

For more information:
https://wpml.org/faq/install-wpml/#automated-updates

Thanks.

October 15, 2025 at 6:31 am #17485695

andraZD

Hi Christopher,

updating the plugin will not solve the problem that it created previously. I do not feel I should play with it before all the image instances are cleaned.

October 16, 2025 at 3:57 pm #17491479

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello,

Our second tier crafted a query to delete the duplicated attachments. This is a risky operation, so please read carefully 🙂

The query creates a temporary table, populates it with IDs from the database, and should remove the higher ID (which are the duplicated images). This will remove all translated images, but I think this is your intention at this stage. In any case, the image "translation" can be done again after this problem is fixed.

This can not be undone, so I suggest you do it in a staging environment and check that everything works as expected before doing it in production. And always, ❌ make a full website backup before proceeding ❌

I tried it locally, and it took some time to run, so you may need to overcome server limitations even with this optimized query. Currently, there are around 400k attachment rows in wp_posts and after running the query it goes down to 19k. Do these numbers make sense to you?

Finally, the query uses wp_ as table prefix, you'll need to modify it if your DB uses another one.

You may want to run it first until step 4 (uncomment the statements) to see how many items will be deleted before actually delete them.

This is the query:

-- 1) Groups that have duplicate attachments by (file path, title)
CREATE TEMPORARY TABLE dup_groups AS
SELECT pm.meta_value AS file, p.post_title AS title
FROM wp_posts p
JOIN wp_postmeta pm ON p.ID = pm.post_id
WHERE pm.meta_key = '_wp_attached_file'
  AND p.post_type = 'attachment'
  AND p.post_mime_type LIKE 'image/%'
GROUP BY pm.meta_value, p.post_title
HAVING COUNT(*) > 1;

-- 2) For each duplicate group, keep the smallest ID among items that have a parent
--    (matches your original logic with p.post_parent != 0)
CREATE TEMPORARY TABLE keepers AS
SELECT MIN(p.ID) AS keep_id, pm.meta_value AS file, p.post_title AS title
FROM wp_posts p
JOIN wp_postmeta pm ON p.ID = pm.post_id
WHERE pm.meta_key = '_wp_attached_file'
  AND p.post_type = 'attachment'
  AND p.post_mime_type LIKE 'image/%'
  AND p.post_parent != 0
GROUP BY pm.meta_value, p.post_title;

-- 3) Collect the IDs to delete: any attachment in a duplicate group
--    that is not the chosen keeper for that group
CREATE TEMPORARY TABLE temp_ids AS
SELECT p.ID
FROM wp_posts p
JOIN wp_postmeta pm ON p.ID = pm.post_id
JOIN dup_groups d
  ON d.file = pm.meta_value AND d.title = p.post_title
LEFT JOIN keepers k
  ON k.file = pm.meta_value AND k.title = p.post_title AND k.keep_id = p.ID
WHERE pm.meta_key = '_wp_attached_file'
  AND p.post_type = 'attachment'
  AND p.post_mime_type LIKE 'image/%'
  AND k.keep_id IS NULL;

-- (Optional) sanity check before deleting:
-- SELECT COUNT(*) FROM temp_ids;  -- how many will be deleted?
-- SELECT * FROM temp_ids LIMIT 50;

-- 4) Delete posts, then their postmeta
DELETE FROM wp_posts
WHERE ID IN (SELECT id FROM temp_ids);

DELETE FROM wp_postmeta
WHERE post_id IN (SELECT id FROM temp_ids);

-- 5) Clean up
DROP TEMPORARY TABLE IF EXISTS temp_ids;
DROP TEMPORARY TABLE IF EXISTS keepers;
DROP TEMPORARY TABLE IF EXISTS dup_groups;

Best Regards,
Otto

October 18, 2025 at 8:12 pm #17496157

andraZD

Hi Otto,

the website has about 10K articles, most have 1 image and some have 2 or more, but 19K seems a lot more reasonable than 400K. There are more on the server of course, because the theme makes different thumbnail sizes but those shouldn't be in the DB / Media library right?

I am currently out of office until thursday so I will talk to the hosting company if they can do this for me as it will be a lot safe than if I do it myself + I can overload the server again.

They will probably charge me quite a lot but there's nit much i can do at this point. But I am not sure that i want to reactivate WPML to be honest as it will start making new copies again as this option seems to be enabled in the options now from previous activation.

Best regards,
Andraz

October 20, 2025 at 1:37 pm #17499800

Otto
WPML Supporter since 09/2015

Languages: English (English ) Spanish (Español )

Timezone: America/Argentina/Buenos_Aires (GMT-03:00)

Hello Andraz,

I understand your concern about reactivating WPML. The latest version should handle it better. But, in any case, this should be done in a staging or development environment and with a reliable backup.

Let me know how it goes, please.

Best Regards,
Otto

The topic ‘[Closed] Media Translation Setup will not finish’ is closed to new replies.