WPML duplicate media: which records and files are safe to remove?

A crowded Media Library after a multilingual-site change does not automatically mean WordPress copied every image file. WordPress stores media as attachment posts, with file paths and metadata attached to those records. A multilingual workflow can create related attachment records for different languages, multiple records can point to the same file, or genuinely duplicated files can exist in the uploads directory.
Those cases need different fixes. Bulk-deleting everything that looks repeated can remove featured images, galleries, translated alt text, product media, or files still embedded in content.
Does WPML duplicate media on disk?
One image can have a translated caption or alt text while both language versions use the same physical asset. A localized illustration can instead have a different file. WPML's media translation guide explains both workflows. Before counting possible storage savings, pick a representative image and trace its attachment IDs, the stored upload paths and the actual files. Two library thumbnails are not two measurements of disk usage.
For example, a product photograph could be shared between English and Spanish while the size chart shown alongside it has translated text baked into the image. Keeping one photograph and two charts may be exactly right. Check the public product in both languages, including the image opened from the gallery, before proposing a deletion.
Define the desired final state
Before changing data, decide whether the site will:
- continue using WPML with corrected media relationships;
- keep multiple languages with a different translation system;
- retain only one language;
- remove translated content while preserving shared media.
A cleanup plan without a target state usually turns into repeated deletion and restoration. URL behavior matters too. Removing a language can require redirects from old language paths, canonical updates, sitemap changes, and a review of external links.
Back up and move the work to staging
- Create a full database backup.
- Back up
wp-content/uploadsseparately. - Confirm both backups can be accessed and restored.
- Clone the current site to staging.
- Pause automated image optimization or offload jobs while records are being inspected.
WPML's current troubleshooting documentation also tells administrators to create a backup before running its repair actions. Those actions are designed for specific relationship, cache, collation, and string problems. They should not be clicked as a generic cleanup sequence.
Build a read-only inventory first
WP-CLI can export attachment records without changing the site:
wp post list \
--post_type=attachment \
--post_status=inherit \
--fields=ID,post_parent,post_title,guid \
--format=csv > attachments-before.csv
To find groups that deserve review, save the following as media-inventory.php outside the public web root and run wp eval-file /private/path/media-inventory.php from the staging installation. It uses the current site's table prefix and reads attachment records without modifying them. On a large library, run it on the private copy since grouping metadata can be expensive.
<?php
// Run with wp eval-file on a private staging copy.
global $wpdb;
$groups = $wpdb->get_results(
$wpdb->prepare(
"SELECT m.meta_value AS file_path, COUNT(DISTINCT p.ID) AS records
FROM {$wpdb->postmeta} m
JOIN {$wpdb->posts} p ON p.ID = m.post_id
WHERE m.meta_key = %s AND p.post_type = %s AND m.meta_value <> ''
GROUP BY m.meta_value
HAVING COUNT(DISTINCT p.ID) > 1
ORDER BY records DESC",
'_wp_attached_file',
'attachment'
)
);
foreach ( $groups as $group ) {
WP_CLI::line( wp_json_encode( $group, JSON_UNESCAPED_SLASHES ) );
}
For one result, list the individual records in the Media Library and inspect _wp_attached_file and image metadata. The WordPress attachment metadata reference explains how original and generated size paths are represented. The GUID in the first export is an identifier, not a reliable current file path. Two identical file paths indicate shared references. Equal hashes at different paths identify equal bytes, but each URL may still be required.
Classify what looks duplicated
Translated attachment records
Separate attachment records may carry language-specific title, caption, alt text, or relationship data while referencing a shared file. If the site remains multilingual, those records may be intentional.
Multiple records pointing to one file
This can be harmless, stale, or broken depending on where each attachment ID is referenced. Search post content, featured-image metadata, galleries, product data, custom fields, and page-builder data before deleting an attachment post.
Separate physical files
Names such as photo.jpg, photo-1.jpg, and translated variants may be distinct files. Compare hashes or file contents, not only filenames and dimensions. Image optimization services can also create derivative formats that should not be mistaken for duplicate originals.
Orphaned records
An attachment with post_parent = 0 is not proof that it is unused. Block content, options pages, theme settings, custom fields, and product galleries can reference unattached media.
Use the least destructive correction
If WPML is still active and the problem matches a documented relationship issue, use the relevant WPML troubleshooting action on staging and recheck the inventory. For media-specific behavior, confirm the current WPML Media Translation settings and documentation for the installed version before changing records.
Do not delete one attachment solely because another ID points to the same path. WordPress's attachment deletion routine can remove the underlying file and its generated sizes. Deleting a record through a normal UI is still a file operation. First identify every retained language, featured image, product gallery, ACF image field and direct URL that depends on the record or the same bytes.
If you find distinct files and a verified unused copy, rehearse one removal on staging. Record both IDs and paths, restore if a consumer breaks, and retest an old post as well as the latest one. A media offload plugin may propagate deletion to remote storage. Verify that the remote object is recoverable. When uncertain, keeping an extra reference is cheaper than reconstructing missing product media.
Validation after each batch
- Open representative pages in every retained language.
- Check featured images, galleries, product media, social images, and structured data.
- Search the browser console and server logs for missing media.
- Crawl for image 404 responses.
- Review language switchers, canonicals, hreflang output, and XML sitemaps.
- Confirm the Media Library count and disk usage changed for the expected reason.
Should you delete WPML completely to remove duplicate media?
A WPML reset and a media cleanup solve different problems. WPML 5.2 blocks Reset while secondary languages remain, as its release notes explain. Removing a language simply to unlock Reset can discard content you meant to keep. Decide which translations, URLs, metadata and files must survive before following the vendor's version-specific troubleshooting procedure.
If multilingual content should remain and only a field displays the wrong attachment, check its language preference in the ACF and WPML guide. If the objective is to retire a language, inventory its landing pages and inbound links separately from its files. Validate one migrated page end to end before expanding the work.
If WPML has already been removed
Do not reinstall, reset, or drop tables until the backup and target state are clear. Record the current plugin versions, WordPress version, database prefix, active languages, URL format, and a sample of affected attachment IDs. WPML support or an experienced WordPress developer can use that evidence to distinguish incomplete uninstallation from a media-reference problem.
The safe outcome is not the smallest possible Media Library. It is a library whose records and files are understood, whose retained content still resolves, and whose removals can be explained and restored.
Keep the database and matching uploads together in your restore rehearsal. For an inherited installation with ambiguous references, WordPress technical support can help investigate the affected records on staging.