The Pug Automatic

Bookmarklet to blog all images from a Flickr page

Written September 11, 2006. Tagged JavaScript, Firefox, Bookmarklets, LiveJournal.

Flickr has some blogging integration, but it only seems to support blogging one photo at the time.

I made a bookmarklet that generates the HTML image tags for the full size version of every Flickr gallery image or thumbnail on the current page. It's wrapped in a LiveJournal "lj-cut" tag, but it should be obvious how to get rid of that if you're blogging elsewhere.

The bookmarklet doesn't actually post the images to a blog, but it does rid you of repeated cut-and-pasting.

I have the Firefox bookmark keyword "ljcut" tied to the bookmarklet, meaning I can type that in the address bar and hit to run it.

The contents of the Flickr page are replaced by the code. Just copy it into your blog.

Right-click this link and bookmark it: LJ-cut from Flickr.

Formatted for readability:

imgs = document.images;
keep = [];
for (i=0; i<imgs.length; i++)
if ((m = imgs[i].src.match(/(http:\/\/.*?static\.flickr\.com\/\d+\/\d+_[a-z\d]+)(_[a-z])?\.jpg/)) && !imgs[i].className.match(/\b(setThumb|nextprev_thumb)\b/) && imgs[i].id!="primary_photo_img")
keep.push('<img src="'+m[1]+'_o.jpg" alt="['+ (imgs[i].alt||"Photo") +']" />');
document.body.innerHTML = "<textarea style='width:100%;height:100%'><lj-cut text=\"The photos.\">\n\n" + keep.join("\n\n") + "\n\n</lj-cut></textarea>";

This will obviously not work if full size images are not available.

Update 2007-03-10

The above no longer works, but try this updated code.