Monday, March 10, 2008

Tumblr hack: A real tag cloud

Tumblr may come up with "real" tag browsing soon, but meanwhile, here's a tag cloud that -- unlike third party services -- uses the actual tags that you assign to your posts.

Basically, the script calls the Tumblr JSON API and processes the posts, 50 at a time (the maximum allowable; configurable). It saves the tags, URLs, and a bit of the content. If there are any remaining posts, it keeps on doing this until it retrieves all of them, or reaches a preset maximum (150 by default, or thrice). It then renders the tags in varying font sizes depending on the total number of times each tag was used.

By default, links are created for each of the tags. Clicking on a tag will generate a list of posts with that particular tag. [ Hey Tumblr! A /tags/<tagname> path that only shows posts with that tag would be nice. :-) ]

I used Jason Levitt's Dynamic Script Tag class to call the Tumblr API as many times as required.

Here's*** the quick-and-dirty demo script showing the tags from my scifaiku site (again). If you do use it, please send me your URL via a comment. :-)

*** Update: The original one didn't use the titles (I had no titles in scifAI, originally) but instead parsed the content up to the first HTML tag. Here is a more generic one, using post titles.


GB said...

just put it up on mine. cool!

Unknown said...

Hi Greg! You may want to try this one instead, as the original code was tuned for scifAI. The new one uses the actual post titles as the links. See the tumblrCallback function for changes.

Maia Bittner said...

Hi Alex, I'm working on putting mine up here:


Todd said...

Hey Alex -

First off, thanks so much for putting this together!

Now, on to the business at hand... I'm trying to get this up and running at and it's not quite working.

It'll only return 3 or 4 posts at most. I tried messing with CLOUD_JSON_NUM and CLOUD_JSON_MAX to no avail.

In fact, as best I can tell, CLOUD_JSON_NUM isn't ever used in the code. And if I set CLOUD_JSON_MAX to 0, I get a 503 error from Tumblr.

Any help appreciated.


Unknown said...

I'm using your tag cloud, too.
And I've the same problem as Todd!
Thanks for any help


i like jesus buns said...

Hey thanks for this neat script: i spent a bit of idle time tooling around with it on my page, and created a crappy hack that puts a tag blurb at the bottom of posts as well. Now if there was some way to do it on the dashboard, i feel like a dumba**, but still, it was fun to play around with:

Hatch said...

Bug Report :-D

Find this line:
cloud_request = new JSONscriptRequest(CLOUD_JSON_URL + '?callback=tumblrCallback&type=regular&start='+cloud_done+'&num='+CLOUD_JSON_MAX);


Also, the script only shows text posts. If you aren't getting very many results, maybe you don't have very many text posts.

Anonymous said...


I've updated mine to

1) include all tags from all types of posts (remove "type=regular" from buildCloud function) and,

2) set the tags to be links to the list of your posts with that tag.

' +cloud_tags[i]+ ' ';

Active here:

Anonymous said...

@joegasper: THANK YOU!

Tag cloud is finally working as desired on my site!

See it in action here...

Peteski said...

got it (sort of) kind the way I want it.


p4tr1ck said...

Just got it all figured out.

NuttyKnot said...

Thanks a lot!
I put it up on my blog

Unknown said...


I was using your script on Tumblr and it was working great. Until recently : it just disappeared. No more cloud. I didn't mess with the code. At first I thought I must have create too much tags, but people are telling me there is no limit on the number of tags you can create. Any idea? And thanks for the hard work.

chadanuk said...

SKS said...

I think I am a confused novice, but where is the actual HTML script to add to my tumblr?


Anonymous said...

help an idiot out.

ive got the script working fine to a point - but how do i get it to break out of the sidebar when displaying a post for a clicked tag?

just click any tag to see my problem