• Resolved CosmicRaptor

    (@cosmicraptor)


    Just downloaded WordPress 4.0. Went to upload an image, and was taken aback by the upload of a thousand (or more) of the same image. My Media Library is now turbo-cluttered. I FTP’d over to my uploads and deleted the image, but the ghosts of the uploads remain.

    I learned WPML Media caused the issue so I turned it off, but the duplicate images still exist. How can I quickly remove all these blank images caused by the conflict?

Viewing 15 replies - 1 through 15 (of 17 total)
  • you don’t see the duplicates via ftp?

    Thread Starter CosmicRaptor

    (@cosmicraptor)

    Nope! My FTP folder is clean and pretty. It’s not quite duplicate images, so much as duplicate “posts”, except the posts are media. I’ve attached a pic of how it looks:

    View post on imgur.com

    I probably should have phrased that better. My mistake.

    stefbonnet7

    (@stefbonnet7gmailcom)

    Would be interested in the solution to this as I have exactly the same issue.

    Yep, same here and it’s driving me insane … Any update guys, or have someone got a working solution to fix this issue. It’s not viable going through all of the 360 pagaes of empty/corrupt images.

    Same problem here – four photos have about 4700 entries for them! (One entry for each photo is attached to a post and shows a thumbnail – the rest look just like CosmicRaptor’s screen capture.)

    Is there a clean SQL command to remove entries with specific filenames that are unattached? Naturally I don’t want to do it in the Media Library 20 at a time.

    Oh, and I’d like to ask CosmicRaptor: When you say that you “turned off” WMPL Media, what exactly do you mean? Just unchecking the checkbox in “Media Translation” that says “Duplicate media attachments for translations”, or disabling the plugin completely? This isn’t my site (I’m just providing some technical help), soI don’t know if there might be images that are indeed being “translated”, so I’m hesitant to just shut it down.

    OK, found some sort of a solution: https://wpml.org/forums/topic/removing-wpml-media-2/
    Somewhere in that post there are three MySQL queries which seemed to have worked (for me at least) So its worth a try I guess. As always make sure you backup your database first.

    Thread Starter CosmicRaptor

    (@cosmicraptor)

    @osaka – I disabled the plugin completely. The SQL code looks promising, so I’ll try that in a day or so.

    For me, the WMPL support post mentioned by millend was not relevant except to give me a clue which tables to look at. The WPML support post was about removing translations (…WHERE language_code != ‘en’), whereas the bad entries in wp_icl_translations in my case all had language_code=’en’. But I figured out that a distinctive of almost all the junk wp_posts entries were that their id’s were not in wp_postmeta.

    First I looked in the Media Library and filtered by “Unattached” and “September 2014” (I didn’t have any in August, so that worked for me). Noting the number of entries, I then did this query:

    SELECT * FROM wp_posts WHERE post_type='attachment' AND id NOT IN (SELECT post_id FROM wp_postmeta)

    The number was slightly lower, but good enough for me, as I knew I could clean up the last few manually in Media Library. To verify which “good” entries those are duplicates of, this works as long as you haven’t started deleting anything manually:

    SELECT min(id)-1, post_title FROM wp_posts where post_type='attachment' and id not in (select post_id from wp_postmeta) group by post_title

    WPML had inserted two related records in wp_icl_translations for each id in wp_posts – a comment and a post_attachment. To see the ones that would be deleted later, you can use this nested subquery:

    SELECT * FROM wp_icl_translations WHERE element_id IN (SELECT id FROM wp_posts WHERE post_type='attachment' AND id NOT IN (SELECT post_id FROM wp_postmeta))

    When you are satisfied that you’re looking at the right records to delete (AND YOU HAVE DONE A BACKUP!), you delete from wp_icl_translations first:

    DELETE FROM wp_icl_translations WHERE element_id IN (SELECT id FROM wp_posts WHERE post_type='attachment' AND id NOT IN (SELECT post_id FROM wp_postmeta))

    Then you can remove the wp_posts entries themselves:

    DELETE FROM wp_posts WHERE post_type='attachment' AND id NOT IN (SELECT post_id FROM wp_postmeta)

    And I have learned that the current version of WPML Media doesn’t have the problem – if you have WPML Media version 2.1.6 (released on August 20th as part of WPML 3.1.7), you should be okay now. They even mentioned the bug in their version announcement: https://wpml.org/2014/08/wpml-3-1-7-improvements-wordpress-4-0-compatibility/ (“Fixed issue with hundreds of duplicated images”)

    Unfortunately, on the site I had to clean up, the site owner upgraded WordPress to 4.0 and uploaded some images before upgrading WPML.

    I had the same problem, so I researched here, updated wpml and erased all the phantom images in my media library…

    So far so good, I hope the update will allow me to upload images now without this problem BUT NO image is showing on my website now although they are on the server! This is horrible and I have no solution! https://www.jessicavoiceover.com.

    Any help would be highly appreciated!

    Are you talking about images that were duplicated, or new ones you have uploaded since the cleanup? If it’s ones that were duplicated, it’s possible that the “attachment” record for the post pointed to one of the copies you deleted instead of the one you still have. Try editing your post and re-linking the image.

    I have not yet dared to upload any image since the cleanup!

    I will try what you suggested though, but neither my logo, headshot or homepage slider images are showing up, meaning, it’s not just post images, it’s all images… All images are completely shot. This must be a wpml issue, but I have NO clue what to do now… The image links are correct…

    Let’s clarify something. There are at least two things that could reasonably be called “links” in this context. I was referring to the act of WordPress associating the database entry for the image with the place were it is used (post, page, plugin, banner, etc.). The other is the actual HTML “a” tag which points to an actual file located on the server. When you say “the image links are correct”, what do you mean? Your browser doesn’t care about WordPress, so if the HTML links are correct, the site will look fine to the outside world. But WordPress uses its database data to create that HTML in many cases, so if the data references are messed up, you will have problems.

    Anyway, currently your site looks fine – did you restore from backup?

    d-phrag

    (@d-phrag)

    My hosting provider keeps files and database backups from a week before current date. I restored those backups (assuming that this will restore the WPML tables as weel). No, I was wrong, the 9,345 images are still there…. this is bad, bad, bad product. Now I regret that I ever turned to them.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Thousands of duplicate images in Media Library after getting WordPress 4.0’ is closed to new replies.