Blog for web developers

Detect duplicate image

Detect duplicate image

Hi folks, today in this tutorials I am going to show you how anyone can easily detect duplicate image inside the page and remove one of them. I am writing this tutorial because recently I have been working in a inbuilt wordpress project where the content and images was already loaded. My job was to create a new theme with existing content. When I import those content in the new theme I found that in all post there were same image repeating. One is coming from feature image and another one was hard coded inside the page. Both the image was coming form the same path. With trying with some simple jQuery script I was able to accomplished this job.

This is how I detect duplicate image with the help of jQuery.

Detect duplicate image with jQuery

    var srcs = [],
    $("body img").filter(function(){
        temp = $(this).attr("src");
        if($.inArray(temp, srcs) < 0){
            return true;
        return false;

I hope you find this tutorial helpful. Thanks for reading.

Santosh Shah

I am a JavaScript developer having enthusiasm on most frontend skills like JavaScript, HTML, CSS, SASS, node, gulp, angular etc. I love exploring new techniques and like to learn new technologies to keep my self up to date.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.