What is the schema of a image-file at Tumblr? (I don't mean HTTP
) I've only figured out that the domain of the servers where images are stored is <n>.media.tumblr.com
, where n
is a number between 1 and 31 and the name of the image file is prefixed with "tumblr_
.
I'm asking because I want to find URLs that refer to the same image.
EDIT: I'm also processing URLs from other sources, not only Tumblr.
On your computer, go to images.google.com. Search for the image. In Images results, click the image. At the top of your browser, click the address bar to select the entire URL.
An image or file url is just the location of where the image/file is being stored. The Universal Resource Locator or URL, tells your computer browser where to find the image file to make it show up on your site.
Right-click your browser's address bar, and select "Paste." The URL for the image appears in the address bar. Press "Enter" to display the image. You can also paste the URL in another application if desired.
When you upload an image to Tumblr, multiple sizes (of the same image) are generated and stored across their network.
Once uploaded, you can use template tags to request this image at the following sizes: 75, 100, 250, 400, 500 and 1280.
It's worth mentioning the following:
The image URL will be either of the two below. The first URL seems to be associated with images upload more than 6 months ago (this is a guess), the second URL seems to be for newer images:
http://36.media.tumblr.com/tumblr_o4qxa0n2BP1r6ec7zo1_500.jpg
or
http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_500.jpg
This can be split into three parts, two variables, one constant.
http://36
.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1
_500.jpg
1 This is a server number and can differ for each image size. AFAIK there is no guarantee that an image size will be available on all servers. @Ally mentioned in the comments you can remove this part from the URL and the image will still be found.
2 This is the Tumblr subdomain, directory (if applicable) and partial file name. This will be the same for all sizes.
3 This is the requested size (which matches the template tag) and file extension.
The only foolproof method I have found is to use the corresponding template tags and assign them to a data-
attribute.
Example Template Code:
<img src="{PhotoURL-100}" data-250u="{PhotoURL-250}" data-400u="{PhotoURL-400}" data-500u="{PhotoURL-500}" data-1280u="{block:HighRes}{PhotoURL-HighRes}{/block:HighRes}" />
Example Rendered Code:
<img src="http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_100.jpg" data-250u="http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_250.jpg" data-400u="http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_400.jpg" data-500u="http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_500.jpg" data-1280u="http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_1280.jpg" >
With this method, you can be certain you have the correct URLs and you know what sizes are available.
Using this information the URL would become:
http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_500.jpg
Below is a test to confirm we access all the available sizes:
You still wouldn't know if the 1280 size has been generated, but its a step closer. With this method you could replace the value (part 3) with an new size and you should be able to get the image.
Do keep in mind that original files (in their full resolution) are stored with the '_raw' suffix, instead of _1280, _500, _250, etc.
They are usually stored on data.tumblr.com currently (their CDN domain).
The path in the URL scheme is generated from the original (raw) file's SHA1 checksum.
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