Getting flickr thumbnail
Asked Answered
M

6

5

I'm trying to get a thumbnail of flickr pictures in PHP.

All I saw was this in their API: http://www.flickr.com/services/api/misc.urls.html

Which is a overkill. In instagr.am/twitpic and others I found a very easy way of doing so (just adding to the url the request).

Is there an option with flickr I'm missing?

Meander answered 21/7, 2011 at 10:48 Comment(0)
S
11

If you have the URL to the Flickr image, all you have to do is modify the suffix to get a different size of the photo. For example:

http://farm1.staticflickr.com/2/1418878_1e92283336_m.jpg

This URL loads the medium sized photo. If we simply change the _m to _t, we would get the thumbnail:

http://farm1.staticflickr.com/2/1418878_1e92283336_t.jpg

You can also use s for small, z for medium, and b for large.

Sophistry answered 16/2, 2012 at 14:32 Comment(0)
B
3

You could just use a PHP wrapper around Flickr API and keep it simple - http://phpflickr.com/

Bernhardt answered 21/7, 2011 at 11:4 Comment(0)
L
0

You can parse the photo's ID out of the URL and get the thumbnail URL via flickr.photos.getSizes. This is likely how Twitpic/Instagram handle it.

Literalminded answered 21/7, 2011 at 11:40 Comment(2)
But for that I got to have an API key and parse the url and than the XML. No way to avoid this?Meander
You could scrape Flickr's pages, but their HTML is subject to change. API keys are free and take 30 seconds to get. You're going to have to do a little parsing of something no matter what. There are plenty of PHP Flickr libraries that'll handle the parsing for you, too.Literalminded
M
0

For future readers, flickr doesn't support the simple functionality that other photo sharing services does. So the answer to my question is you can't.

Meander answered 24/7, 2011 at 16:59 Comment(0)
R
0

If you know the username of the flickr user you can try to use this small bot. It uses the feed to retrieve the last images of the user, so it works only on the last images... I hope it will help you.

Reiners answered 22/8, 2011 at 9:20 Comment(0)
I
0

Use the getPhotos api call:

https://www.flickr.com/services/api/flickr.photosets.getPhotos.html

Then follow jamal's suggestion on mapping.

 return sprintf('https://live.staticflickr.com/%s/%s_%s_%s.%s',
            $record['server'],
            $record['id'],
            $record['secret'],
            $size,
        $format
        );
Impotence answered 3/6 at 1:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.