Changes between Version 2 and Version 3 of FlickrIntegration


Ignore:
Timestamp:
Jul 1, 2006, 1:07:38 AM (18 years ago)
Author:
Tyson Tate <tyson@…>
Comment:

Added better get_pic_url()

Legend:

Unmodified
Added
Removed
Modified
  • FlickrIntegration

    v2 v3  
    119119
    120120 * You'll need to run the sync_flickr_photos function at a reasonable interval. Don't flood flickr with API calls every time someone view's your page. For instance, I use signals and the dispatcher to raise a signal whenever someone visits my photos page. If it's been more than 15 minutes since the last time I synchronized, I run the function.
    121  * To actually do anything useful with your flickr information, you'll need to create methods that build the URLs. Here's how I get a URL to a small picture (240px on longest side):
     121 * To actually do anything useful with your flickr information, you'll need to create methods that build the URLs. Here's how I do it:
    122122
    123123{{{
    124124#!python
    125 def get_med_pic_url(self):
    126         return "http://static.flickr.com/%s/%s_%s_m.jpg" % (self.flickr_server, self.flickr_id, self.flickr_secret)
     125def get_pic_url(self, size='small'):
     126        # small_square=75x75
     127        # thumb=100 on longest side
     128        # small=240 on longest side
     129        # medium=500 on longest side
     130        # large=1024 on longest side
     131        # original=duh
     132       
     133        base_url = "http://static.flickr.com"
     134        size_char='s'  # default to small_square
     135       
     136        if size == 'small_square':
     137                size_char='s'
     138        elif size == 'thumb':
     139                size_char='t'
     140        elif size == 'small':
     141                size_char='m'
     142        elif size == 'medium':
     143                size_char='-'
     144        elif size == 'large':
     145                size_char='b'
     146        elif size == 'original':
     147                size_char='o'
     148       
     149        return "%s/%s/%s_%s_%s.jpg" % (base_url, self.flickr_server, self.flickr_id, self.flickr_secret, size_char)
    127150}}}
    128151
Back to Top