You can use only the first "if" part, the second is not to block Google and other image spiders. First part looks for referers from mydomain (and google, etc) and returns 444 in other cases. It can be replaced to return blank.gif image.