Is it possible to detect if an image has been loaded via:
<img src="image.jpg"/>
Versus in the address bar or linked to directly via:
<a href="image.jpg">Image</a>
Thanks.
No, in general it is not.
The browser will issue the exact same request for both.
When the browser parses the HTML (first thing it gets), each additional resource (JavaScript, CSS, image and other linked files) will be requested separately. Browsers do not add information about where they got the reference from - so it is not possible to tell from the request whether it was directly on the address bar or from a reference on an HTML page.
You could query the logs to see if the request is all on its own or if a request to the HTML page (and possibly other resources) have been done around the same time. This is not fool proof (think about the multiple levels of caching we have on the web).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With