25

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.

2 Answers 2

54
+350

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:

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.

27
  • 1
    It is possible, but it is not fail safe. Originally I was taking the URL and replacing (part 3) with a different size. However it turned out that in some cases that image with the new size wasn't on the same server (part 1) as the previous size. You could probably do something like testing a URL for a response, if 404, increment the server number, rinse and repeat, but it is hacky. Can I ask why you can only get the img URL? May 30, 2013 at 14:30
  • 2
    Generally speaking, you don't need the number for the server. http://media.tumblr.com/... should work. If you dead set on using the server number though, I'm not sure how to grab that outside of Tumblr. I'll give it some thought.
    – Ally
    May 30, 2013 at 14:57
  • 1
    @mikedidthis I tested you theory but it is not true. But I got curious and so I went through a big blog and checked the URL of the images. I came to the point that 5/6 months ago Tubmlr must have changed the system, because before that time no picture was located in a directory.
    – Jimmy T.
    May 30, 2013 at 16:26
  • 2
    Atention! I just realized, tumblr does not allow to use part1 without server number anymore. this answer just became outdated. Apr 20, 2015 at 13:27
  • 2
    FYI: as @DavidMabodo said, server number is still mandatory. Could you refresh the text a bit? It's not critical though. All the rest of information seems to be valid. Apr 13, 2016 at 13:55
1

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.

2
  • Do you have an example of what you're saying? I'm unable to make it work... EDIT: I think it changed just yesterday...
    – mcont
    Aug 10, 2018 at 10:40
  • 1
    Yes, unfortunately, since two days ago Tumblr is now denying access to _raw files. One more reason to never use this trash site.
    – Hernn0
    Aug 11, 2018 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.