Module: FlickrPhoto
- Defined in:
- lib/objectiveflickr/flickr_photo.rb
Overview
This helper module provides a set of utility methods for Flickr photos. Methods such as unique_id_from_hash and url_from_unique_id are helpful when you try to move the photo id data to and fro your web apps.
Class Method Summary collapse
-
.buddy_icon_url(nsid, icon_server = nil, icon_farm = nil) ⇒ Object
Helper that gets you the URL of the buddy icon of a given user.
-
.default_photo_url_base(b) ⇒ Object
Set the default photo base URL, without the http:// part.
-
.element_id_from_hash(params, prefix = 'photo') ⇒ Object
This utility method combines the Flickr photo keys (from which one gets the real URL of a photo) into a photo id that you can use in a div.
-
.hash_from_element_id(uid) ⇒ Object
This utility method breaks apart the photo id into Flickr photo keys and returns a hash of the photo information.
-
.hash_from_unique_id(uid) ⇒ Object
DEPRECATED–Call hash_from_element_id instead.
-
.unique_id_from_hash(params, prefix = 'photo') ⇒ Object
DEPRECATED–Call element_id_from_hash instead.
-
.url_from_element_id(uid) ⇒ Object
This utility method breaks apart the photo id into Flickr photo keys and returns the photo URL.
-
.url_from_hash(params) ⇒ Object
This utility method returns the URL of a Flickr photo using the keys :farm, :server, :id, :secret, :size and :format.
-
.url_from_unique_id(uid) ⇒ Object
DEPRECATED–Call url_from_element_id instead.
Class Method Details
.buddy_icon_url(nsid, icon_server = nil, icon_farm = nil) ⇒ Object
Helper that gets you the URL of the buddy icon of a given user
20 21 22 23 24 25 26 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 20 def self.buddy_icon_url(nsid, icon_server=nil, icon_farm=nil) if !icon_server || icon_server.to_i == 0 return @default_buddy_icon end "#{self.photo_url_base(icon_farm)}/#{icon_server}/buddyicons/#{nsid}.jpg" end |
.default_photo_url_base(b) ⇒ Object
Set the default photo base URL, without the http:// part
29 30 31 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 29 def self.default_photo_url_base(b) @photo_url_base = b end |
.element_id_from_hash(params, prefix = 'photo') ⇒ Object
This utility method combines the Flickr photo keys (from which one gets the real URL of a photo) into a photo id that you can use in a div
50 51 52 53 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 50 def self.element_id_from_hash(params, prefix='photo') p = self.normalize_parameter(params) [prefix, p[:server], p[:id], p[:secret], p[:farm], p[:size], p[:format]].join("-") end |
.hash_from_element_id(uid) ⇒ Object
This utility method breaks apart the photo id into Flickr photo keys and returns a hash of the photo information
NOTE: No sanitation check here
65 66 67 68 69 70 71 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 65 def self.hash_from_element_id(uid) p = uid.split("-") { :server=>p[1], :id=>p[2], :secret=>p[3], :farm=>p[4], :size=>p[5], :format=>p[6], } end |
.hash_from_unique_id(uid) ⇒ Object
DEPRECATED–Call hash_from_element_id instead
84 85 86 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 84 def self.hash_from_unique_id(uid) self.hash_from_element_id(uid) end |
.unique_id_from_hash(params, prefix = 'photo') ⇒ Object
DEPRECATED–Call element_id_from_hash instead
74 75 76 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 74 def self.unique_id_from_hash(params, prefix='photo') self.element_id_from_hash(params, prefix) end |
.url_from_element_id(uid) ⇒ Object
This utility method breaks apart the photo id into Flickr photo keys and returns the photo URL
57 58 59 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 57 def self.url_from_element_id(uid) self.url_from_normalized_hash(self.hash_from_element_id(uid)) end |
.url_from_hash(params) ⇒ Object
This utility method returns the URL of a Flickr photo using the keys :farm, :server, :id, :secret, :size and :format
The :type key that is used in ObjectiveFlickr prior to 0.9.5 is deprecated. It is still supported, but support will be removed in 0.9.6.
Since January 2007, Flickr requires API libraries to support :originalsecret and :originalformat
42 43 44 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 42 def self.url_from_hash(params) self.url_from_normalized_hash(self.normalize_parameter(params)) end |
.url_from_unique_id(uid) ⇒ Object
DEPRECATED–Call url_from_element_id instead
79 80 81 |
# File 'lib/objectiveflickr/flickr_photo.rb', line 79 def self.url_from_unique_id(uid) self.url_from_element_id(uid) end |