• Resolved DexterG

    (@dexterg)


    In Media Library Folders or in WP Media (list view) when I sort by name images show up multiple times. If I sort by date images are not repeated. What is going on here?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author AlanP57

    (@alanp57)

    I would expect the WP Media list view to show all images in the media library while in Media Library Folders, the page can only display the files in a particular folder. I tested several folders to see if there was a difference in the number of images when I change the sort order and did not find any.

    Thread Starter DexterG

    (@dexterg)

    That is helpful to know. Since I am relatively new to WordPress, I have no idea what is expected behavior and what is an indication of a problem. Smile.

    Perhaps it would be helpful if I explained how I got to this place. The website that I am working on is at least 10 years old, and the media library had multiple copies of identical images uploaded on different dates by different people and used in different articles. Sometimes the images were named differently even though they were the exact same image. I decided the best way to sort out this mess would be to get your plug-in, create a single image folder, and then move all of the images into it. I then proceeded to rename or delete all of the duplicate images thinking that the references to them would all resolve to the one remaining canonical image. What happened, however, is that WordPress continued to retain the original image names and upload dates in its database even though many of these are now pointing to the same image.

    For some reason when I view the images in the WP Media Library using Grid View and the default sort order, which appears to be by date, it shows only one occurrence of each image, but when I switch to List View and click on “File” to sort them by name it shows all of the duplicate references to each image, buy original name or upload date, as a separate copy of that image. And if I try to delete/remove any of these extra copies it also deletes the one actual image. What I have described above occurs in both Media Library Folders and WordPress Media because in my case there is only one images folder (uploads/images). I also created an uploads/pdfs folder, but that is irrelevant to this particular problem.

    I wonder if I should delete all of my images from the media library and then re-import them from a local copy? But I assume that would break all of their placement links in every article and as feature images?

    Hi Dexter,

    Can you look into the folder that contains the images with FTP? If you can take a look if you see the images twice as you indicated. And if so do look at the exact name and extension. You could have the originals, but also thumbnail for the image. But also if the image is large you will see another imagename that is the same but has a slightly different name, because the original is split into parts.
    Maybe this could help solving your problem
    Regards,
    Peter

    Thread Starter DexterG

    (@dexterg)

    Yes, I have SFTP access and I have confirmed that the actual image files only occur once. However, the WordPress Media Library creates two references to the same image file based on the dates when the original duplicate images were uploaded. I’ve since removed the duplicate files but the duplicate references still remain, both pointing to the same jpg image file. Here is an example of this:
    https://synearth.net/armstrongjpg/
    https://synearth.net/armstrongjpg-2/
    Here is another:
    https://synearth.net/earthpeoplejpg/
    https://synearth.net/earthpeoplejpg-2/

    Apparently, this condition (having multiple references to the same image) was the result of moving all of the images (including duplicates) to one folder (from the many date folders that they were originally uploaded into) using the MFL plugin.

    Ok good to see there are no other files present.
    You can get rid of the duplicate links by using the MLF reset plugin.
    To do that, you need to disable MLF, and activate the MLF reset plugin.
    Read the docs how this works.
    Basically it resets the database, and then disable the reset plugin, followed by activating MLF again.
    The plugin will scan the files and correct the links also for the standard media library

    Thread Starter DexterG

    (@dexterg)

    I tried that this weekend but it made no difference. Just tried it again, no change.

    In the MFL Reset plugin I noticed an option to “Display Attachment URLs”. When I did this it showed two unique Attachment IDs for the each duplicate image. I’m not sure if this is significant or not, but I thought it might be useful information to share.

    Hi Dexter

    That is something Alan needs to answer.
    Did you remove images with FTP instead of MLF?
    If you remove images with FTP, MLF is not aware of that fact. Maybe a plugin that fixes missing links can help you clean your database:https://www.ads-software.com/plugins/media-cleaner/
    Please make a backup before using this plugin.

    Thread Starter DexterG

    (@dexterg)

    I manually removed the duplicate Post and Post_Metadata entries from the WP database using phpMyAdmin and everything is working OK now. Both Name sort and Date sort are showing the same number of images with no duplicates. Hooray! Thanks for your help.

    Hi Dexterg

    Well done thanks for letting us know your problem is solved and MLF is working as expected.
    Regards,
    Peter

    Thread Starter DexterG

    (@dexterg)

    For the benefit of those who will read this thread in the future, I would like to clarify that my initial understanding of the problem was incorrect. Sorting by name in MLF was not causing the image duplication but simply making it apparent to me. Because I have so many images, going back more than 10 years, the duplication was not apparent when sorted by date because the duplicates were spread across multiple pages.

    Sometimes there were two, three, or even four registrations in the database of the very same image file! And deleting any one of them would delete the actual file, leaving the additional copies as orphans. I tried running a deduplication plugin to fix this, but since the actual image files no longer existed the program was unable to fix this problem.

    And even more frustrating was that if I re-uploaded any of the deleted images the duplicate copies would immediately reappear! That’s because there were still references in the WP database to that file name. What I ended up doing to fix this problem was going into the database directly using phpMyAdmin and searching for and deleting these duplicate references to the image files manually. They existed in both the “posts” and the “postsmeta” tables. This was an all day process but I ended up finding and removing 56 of them. Once I cleaned up the database I could re-upload the images without any of them appearing as duplicates.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘When I sort by name images show up multiple times’ is closed to new replies.