1

I have 8 thumbnails on a page that are being pulled from another site. When no image is found the site sends back a standard 80x80 (natural dimension) image. I need to detect that 80x80 image and replace it with one of my own.

I'm guessing this can be done with jquery but honestly don't have a clue how to achieve it.

Any help would be much appreciated.

FIXED: I came up with a solution but not sure if it's the best one. It works so I'll use it for now.

<script type="text/javascript">

jQuery(document).ready(function(){
    jQuery('img').each(function(index){
        var img = jQuery(this);
        var newImg = new Image();

        newImg.src = img.attr('src');

        if(newImg.height == 80 && newImg.width == 80){
            jQuery(this).attr("src", "/2/files/no_image.jpg")
        }
    });
});

</script>

Thanks

Steve

Lux Interior
  • 311
  • 4
  • 12

1 Answers1

0
<script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('img').each(function(index,value){
            var img = jQuery(this);
            if(img.height == 80 && img.width == 80){
                img.attr("src", "/2/files/no_image.jpg");
            }console.log("Not found")
        });
    });
</script>
Sultan Khan
  • 308
  • 2
  • 11