Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the URL schema of Tumblr images?

Tags:

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.

like image 302
Jimmy T. Avatar asked May 30 '13 09:05

Jimmy T.


People also ask

How do I find the URL for an image?

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.

What is an image file 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.

How do you link pictures on Tumblr?

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.


2 Answers

Overview

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:

  1. The value in the template tag is the maximum size the requested image will be. Example: A 400 version of an image could be anywhere between 251px and 400px wide / high.
  2. There may not be a high res or 1280 version of an image available. If the original image is 500px or less, a 1280 version isn't generated.
  3. Photosets don't produce a 100 version.

Image URL

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 

URL Schema

This can be split into three parts, two variables, one constant.

  1. http://36
  2. .media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1
  3. _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.

Generating URLs for all sizes available using template tags.

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.

Hacking all size URLs based on just one URL.

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:

  • http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_100.jpg
  • http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_250.jpg
  • http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_400.jpg
  • http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_500.jpg
  • http://36.media.tumblr.com/83099a60d4e0cbeeb30d90394e222878/tumblr_o4qxa0n2BP1r6ec7zo1_1280.jpg

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.

like image 138
mikedidthis Avatar answered Oct 29 '22 06:10

mikedidthis


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.

like image 24
Hernn0 Avatar answered Oct 29 '22 06:10

Hernn0