Hide product thumbnail image, If it’s a gif image

So here is the code:

$( ".product-thumbnails img" ).each(function() {
  if ($(this).attr("src").indexOf(".gif") > -1) {
     $(this).css("display","none");
  }
});