/ Published in: JavaScript
A short photo id is a base58 conversion of the photo id. Base58 is like base62 [0-9a-zA-Z] with some characters removed to make it less confusing when printed. (namely 0, O, I, and l).
So that leaves an alphabet of: 123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ
So that leaves an alphabet of: 123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function flic_kr(aPhotoId) { // aPhotoId argument is Flickr photo id if (typeof aPhotoId !== 'number') { aPhotoId = parseInt(aPhotoId); } var enc='', alpha='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'; var div = aPhotoId, mod; while (aPhotoId >= 58) { div = aPhotoId / 58; mod = aPhotoId - (58 * Math.floor(div)); enc = '' + alpha.substr(mod, 1) + enc; aPhotoId = Math.floor(div); } return shortURL = "http://flic.kr/p/" + (div ? '' + alpha.substr(div, 1) + enc : enc); }
URL: http://www.flickr.com/groups/api/discuss/72157616713786392/