When I built some image galleries for this site, I had to get cozy with Flickr’s developer API. There are a few gotchas in there, so I thought it would be nice to save someone else a few minutes of headache and just post some answers. Today’s gotcha involves the way Flickr’s image suffixes work.
If you go look at the sources for Flickr images, you’ll notice that they tend to end with an underscore and a letter. This is how Flickr sorts out which size to serve up. For example, a suffix of “s” means that you want a 75×75 pixel square. There’s a list of the suffixes here, along with some excellent example urls.
There’s one confusing point on that page, however: There is no “-” suffix. They wrote that to indicate that there’s nothing. If you try to load an image with a dash in the name, you’ll get a broken link. It’s also important to note that the underscore is part of the suffix. A standard-sized image has no underscore.
/* _s small square 75x75 _q large square 150x150 _t thumbnail, 100 on longest side _m small, 240 on longest side _n small, 320 on longest side - medium, 500 on longest side - THERE IS NO SUFFIX AT ALL. _z medium 640, 640 on longest side _c medium 800, 800 on longest side † _b large, 1024 on longest side * † Medium 800 photos only exist after March 1st 2012. * Before May 25th 2010 large photos only exist for very large original images. */
Example of a Suffix in Use
So an example of a correct image source for an image that’s
640px on the longest side would be:
/* https://c1.staticflickr.com/9/8890/17171767930_3a7a2b430c_z.jpg */
Example of an image Without a Suffix
If you want something at the default size of
500px on the longest side, then you would use no suffix at all:
/* https://c1.staticflickr.com/9/8890/17171767930_3a7a2b430c.jpg */
Here’s a direct image link from the Flickr example pages that you can use to swap out suffixes and play around. It may seem like a small thing, but when you’re coding late at night and you’re avoiding coffee because you need to sleep someday, that dash in the documentation can be a serious source of consternation. Hopefully I’ve saved you a bit of that.