Many websites, reddit included, make it difficult or possibly impossible to simply view an image, by itself, without the accompanying website around it, even when you click “open image in new tab”. How does this work, and is it possible to force the browser to just show the image?
edit: yes I know *why* websites do it, it’s because they’re jerks and don’t want it embedded. the question is more about why web browsers just go along with it. if I tell my web browser to display an image, I obviously don’t want it to display an entire website, and that shouldn’t be something the website can control.
In: 9
The truth is – it’s not difficult at all. Early 2000s pages often did just that. But then the question arose – why would websites choose to do this?
They would be wasting traffic on displaying an image, you would leave the site without links to go back / other recommended content and there would be no revenue in advertisement.
So yes, “open image in new tab” is the best you’ve got, and some websites make it explicitly difficult to use that function as well. That’s on purpose.
I think what you’re seeing is .webp images. They are a new format made by Google that works differently. For one, the quality of the image depends on what your browser needs it to be, so not everyone is getting the exact image. It’s hard to view because it works more like an animated .gif.
Often when you see one of those short videos that repeat and have no controls, those are actually these same files. In both cases, something has to decide what it is before it can decide what to do with it.
Not sure what browser you’re using, but I have no trouble opening the image in a new tab on chrome, and I use Irfanview to view them, not sure what other image software works with it, I’m assuming most.
The other comments covered the why, so I’ll take a crack at covering **how**.
When your browser tries to open a URL, it really just connects to the server at the IP address that the domain (for example www.reddit.com) points at, and then passes the rest of the URL, along with some other information, to the server and waits for a response.
What response the server gives is entirely up to how it is configured. You can make a server that is configured to respond with an image file in response to you asking for theimage.jpg on yourdomain DOT com on weekdays, but a text file containing ‘Gone for the Weekend’ during the weekend instead.
This configuration could also take into account some of the information that your browser sends besides the URL itself. One of these pieces of information is what is called the ‘Referer’ ([Yes, the mispelling of Referrer is intentional](https://en.wikipedia.org/wiki/HTTP_referer)). When your browser renders a webpage, it usually needs to download all sorts of additional images and other files to be shown on it. The webpage itself specifies the URLs to all of these pages, and your browser then automatically makes additional requests to the server to get these files. Each of these additional requests will have the URL of the webpage itself set as their ‘Referer’, and the server can then see this to determine if you’re trying get an image because you’re viewing the webpage it is shown on, or you’re trying to open the image file directly (in which case no ‘Referrer’ data would be sent).
So what is sorta happening with Reddit images is that when you try and open it in a new tab, the Reddit server sees that you’re trying to access the URL directly, and just serves you the webpage it is shown on as the response. But when your browser then requests the same URL as part of rendering the webpage, the server responds with the actual file because it it can see that you’re already on the webpage showing it.
Your browser has no control over what response the server decides to respond with. The way the browser behaves with the ‘Referer’ data has been part of HTTP browser standards for ages and was included in the standard to begin with precisely to give servers the ability to vary how they respond based on it. This is unlikely to change just because some sites decide to use it in a user-unfriendly way.
If this practice becomes prevalent enough among larger websites, I’d expect browser plugins to start popping up that allows you to fake the type of requests that show the actual image when you open them in a new tab.
Latest Answers