• Hello,

    I want to know something about the duplicated (used) images in pages/posts in WP image gallery.

    Ex. Scenario:
    In Page A – the uploaded image name is Image A
    In Page B – the uploaded image name is Image B
    (Image A & Image B are same images, but a different name)
    So here is a duplication.. How to delete the duplicate image safely without the page affect? Is this possible?
    or this will be a manual hand work (by deleting the Image B in gallery & re-upload the Image A in the Page B) ?

    Kindly check & answer.
    Anyone..

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator bcworkz

    (@bcworkz)

    You would need to edit the page with the duplicate image to refer to the remaining image instead. No need to actually re-upload or anything, just change the URL in the image reference. This can be done through the page’s code editor. Or use the block dialog to update it so it refers to the remaining image.

    If it were impossible to edit the page for some reason, it is possible to set up a rewrite rule so requests for the deleted image get served the remaining image, but it’s infeasible to do this on a large scale with numerous removed images, unless their naming scheme follows a rigid structure so the rewriting can be done by algorithm.

    Note that by reusing an existing image in posts that it was not originally uploaded for, there will be no attachment relationship between the post and the image. This is usually not an issue unless there’s some unusual reliance on such a relationship, such as some gallery code that automatically generates a gallery out of all images on the page by way of their attachment relationship.

    Thread Starter hemasusi

    (@hemasusi)

    Hi @bcworkz
    Thanks for the reply.

    So I need to delete the duplicate image(Image B) & have to remove the Image B & choose Image A in the Page B ??

    Moderator bcworkz

    (@bcworkz)

    That’s correct. IMO, it’s rarely worth doing. Having a few duplicates isn’t that big of a deal in most situations, even if it does offend our sense of order and efficiency. If there are so many duplicates that it affects available server resources, it’s usually too many to consider manually altering the affected pages.

    Thread Starter hemasusi

    (@hemasusi)

    Hello @bcworkz
    Thanks. Very helpful.

    Thread Starter hemasusi

    (@hemasusi)

    Hello @bcworkz

    For this, i need one more thing to know that, we have to take backup of image gallery. Then will do this process of removing duplicate images & replace the original image for the respective page.
    After that, we want to restore the backup of gallery folder in any error case.

    So may i know the plugin or any procedure to do this?
    @bcworkz or Anyone know?
    Kindly answer.

    Moderator bcworkz

    (@bcworkz)

    Are you using the Gallery Block for these galleries? Or the older [gallery] shortcode? Or some other gallery plugin? Updating the Gallery Block is pretty complicated to do automatically via code. Any code capable of doing so would be inherently fragile IMO. The shortcode gallery is much easier, each duplicate ID reference only needs to be updated with the proper non-duplicate ID. A gallery plugin will have its own way to manage what images are in a gallery. Updating plugin data will vary by plugin. The plugin’s devs would be in the best place to suggest how to accomplish duplicate removal.

    Because of the complexity of updating a Gallery Block, I’m skeptical that a plugin exists to do so automatically. TBH, I don’t know if there is such a plugin or not.

    To manually update a Gallery Block, open the media library via the “Add” option. In the library, go to the “Edit Gallery” view to remove the duplicate, then use the “Add to Gallery” view to select the original image.

    Thread Starter hemasusi

    (@hemasusi)

    Not using shortcode…
    Its a normal gallery block i think – https://prnt.sc/cqc1z5FM-Inh

    Moderator bcworkz

    (@bcworkz)

    Can’t tell which it is from your screen shot. I’m not entirely sure what Library Recovery does. I think it’s only indirectly related to galleries. Your galleries are likely Gallery Blocks as described here. You can manually edit their content as I described earlier, and as explained on the linked page.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Duplicate Images in Image Gallery’ is closed to new replies.