What’s with really long urls? A lot of times I am looking for a photo to link and the URL for the photo looks like this. I think if you assigned a code number to every quark in the known universe, you wouldn’t need this many characters to get them all. Why are there so many characters? I assume these are system generated, but…why? (The link is to a picture from the Tick)
Bonus question: why don’t they parse as an image here? And can anything be done to make them work as links?
When I search for an image, and do “open image in new window”, this..thing…is what is in the URL slot at the top of the page. And there is an image on the screen.
That’s the same image that @Joey_P posted, just hosted on a different server.
(Web dev here) And yes, data:// URLs are a real thing. They are sometimes used to embed lots of small images (like tiny icons) on a webpage where you wouldn’t normally want to create a bunch of separate network connections to download each individual image. This can be faster in some circumstances, because the same connection can download all the images inside the HTML file itself. But that’s less important these days since connections are generally faster, and newer protocols like HTTP/3 can help reuse existing connections and “multiplex” them.
Sometimes, you also just see these sorts of URLs in (IMHO) poorly made websites where the framework embeds images or other files into data URLs for no good reason. I’d personally consider it a bad practice for any larger images (especially bigger PNGs and JPEGs) because then they can’t be properly cached by the browser or reused across pages. I would normally consider this a mistake unless the framework (or developer) had a valid and specific reason for doing this.
If someone (a person or a website) gives you a data URL and asks you to do something with it… eh… chances are it’s a scam (or maybe a mistake, if the other user doesn’t know what they’re doing and accidentally copied one from a source). There’s rarely ever a good reason to do that if you’re not a developer working with other developers. There are occasional legitimate uses for them, but they’re quite rare and niche.
Base64, on the other hand, is just a common way to encode arbitrary binary data into a safer text string: How Base64 Encoding Works
It is used everywhere… in data URLs, yes, but also in email attachments and various other situations. In and of itself it isn’t good or bad, but sometimes it is used (as any encoding could be) to disguise/obfuscate malware and bad code, so if you see it somewhere unexpected, that can be a sign that something might be amiss.
If you copy and paste that into the browser URL bar, you can play a simple little 3D shooter (arrow keys to move, mouse to shoot):
The QR code encodes a Base64 data URL which contains a gzipped HTML page with a canvas and Javascript that generates a 3D level and runs the game. It’s more a “tech demo” than a practical use case, but it illustrates what the data URL can hold. It can also just as easily encode malware, though, so don’t just run random data URLs you find online… including this one
On a normal Discourse forum, you should be able to put that into an <img> tag like <img src="data:image/jpeg;base64,blahblah..."/>. But on the SDMB, we’ve disabled embedded images (of all sorts, not just in data URLs). It will work on preview, but when you try to actually submit the post, you’ll get an error saying “Sorry, you can’t embed media items”.
So you have to first upload that image somewhere else. Where did you get it from? It’s odd that you don’t have a direct URL for it (maybe it’s a copy prevention measure?).
You can copy and paste the whole data URL into a new browser tab. It should load as an image. Then you can right-click and save it onto your computer. Then you’ll have to upload it somewhere else (like Imgur) and then copy and paste the link here. (This is a SDMB restriction, not a data URL issue.)
To be annoyingly pedantic. There are two things here. URLs and URIs.
URI = Universal Resource Identifier.
URL = Universal Resource Locator.
All URLs are URIs. But not all URIs are URLs. A URI does not need to contain a location, and can directly carry the identified data, such as is done here.
URIs are wider than the web. They get used for other protocols, for instance
tel:+1-816-555-1212
is a perfectly good URI.
If you want to reference the identified entity elsewhere, it needs a location, and the URI generally becomes a URL.
They [Data URLs] were formerly known as “data URIs” until that name was retired by the WHATWG.
I guess that makes sense for the WHATWG, being by its nature a more practical, descriptivist group than the “real” standards bodies that came and went before it.
Standardize on the term URL. URI and IRI are just confusing. In practice a single algorithm is used for both so keeping them distinct is not helping anyone. URL also easily wins the search result popularity contest.
What the WHATWG wants, everyone else gets… as far as browsers and the Web go, at least, they dictate reality. Maybe that’s not the case for URIs outside the web context (like ISBNs?)? Not sure.
I did a general search for “gravity is a harsh mistress” image, and every one I found was a data URI. I seem to remember I used to have much better luck finding straight jpeg links, but not any more. Took me several tries to get my Johnny Carson one.
And now that I am home, i can see the two versions that were white squares on my other computer.
Where…? On Google Images, you should be able to either copy/save the image as a file, or copy its URL as a regular URL: gravity is a harsh mistress - Google Search (don’t just right click and click open image in new tab, first regular click on it and then do the actual operation on the bigger popup image).
I don’t know why Google loads all data URLs on that page instead of regular thumbnails. Shrug. Maybe an anti anti-copy measure or maybe it’s just faster then loading a bunch of small thumbnails.
Typically most long URLs are transmitting some sort of data to or from the server beyond just the domain and path. This Base64 method is just a way to actually embed the image in the URL itself. It’s basically the way people used to transmit data files via Usenet back in the day (it was Uuencode, but close enough). You’d see a post with like “Michael Jackson “Beatit.mp3” (1/6)” and then the other five pieces, and the text of the post was that same sort of weird looking text. You’d save them down (or toward the end, your newsreader could directly decode them) and decode them, and your decoder would produce a mp3 file presumably containing the song.
Of course, this was a bit of a crap shoot, in that you could spend all night downloading some uuencoded file from the internet in 1991 of some hot naked celebrity or other, like my roommate in college did, only to call all your buddies into the dorm room, decode the file, and find out it’s a blurry picture of some other guy’s flaccid dong. I about injured myself laughing when that happened.
Or, of course, to find that one of those six posts accidentally included an extra space or something in it, or you missed a letter when copy-pasting, and as a result the entire file ended up undecodable.