Search code examples
javascripthtmlonerror

Detect if image is blocked by proxy


I have a webpage which has games on. I realize that there will be accessed from schools (mainly because me and my friends will be using it). I wish to see if a specific image is blocked and display seperate content, which i know isn't blocked by my schools specific proxy.


Solution

  • A simple way would be to use JavaScript to measure the image after it's been loaded. If it doesn't have the image's original dimensions, it's been blocked or altered.

    This doesn't work if the Proxy substitutes content with the same size, though, of course.

    The onerror event (that you are already pointing out in the tags) might work, too, but it will depend on the Proxy. If it just sends an empty image in place of every blocked one, the error event will not fire.