Class to describe a photo from Flickr.
Instances of this class are created to hold photos who have been returned in data from calls to the Flickr API.
This code and documentation is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.0. http://creativecommons.org/licenses/by-nc-sa/2.0/
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0.5.0
Kelvin Luck < kelvin at kelvinluck dot com >
$Id: Photo.as 84 2007-03-11 21:18:17Z kluck $
| com. kelvinluck. flashr. core. Photo | Class to describe a photo from Flickr. |
| id | This photo’s id. |
| owner | A reference to the Person who owns this photo. |
| secret | This photo’s secret. |
| server | This photo’s server. |
| farm | This photo’s farm. |
| originalFormat | The format that this Photo was originally uploaded in. |
| title | This photo’s title. |
| description | This photo’s description. |
| numComments | The number of comments this photo has. |
| _comments | The Comments that have been left on this Photo. |
| _notes | The Notes that have been left on this photo. |
| _tags | The Tags that are associated with this photo. |
| _sizes | The PhotoSizes that are associated with this photo. |
| isPublic | Whether or not this photo is public. |
| isFriend | Whether or not this photo is by a friend. |
| isFamily | Whether or not this photo is by a family member. |
| geoPerms | GeoPerms describing who may view geo data for a photo. |
| dateUploaded | The date this photo was uploaded |
| dateTaken | The date this photo was taken. |
| dateUpdated | The date this photo was updated |
| license | The License for this Photo. |
| rotation | |
| photoPageUrl | The link to this photo’s page on flickr.com. |
| location | The GeoLocation of this Photo. |
| smallSquareUrl | The URL for the small square (75x75 pixels) version of this Photo |
| thumbnailUrl | DEPRECATED This is the 75 x 75 pixel thumbnail image refered to as “small square” in the flickr.com documentation. |
| thumbUrl | The URL for the thumbUrl image (100px on longest side) NOTE - this is referred to the “thumbnail” image on flickr.com but for historical reasons it is known as thumbUrl here (thumbnailUrl points to smallSquareUrl) |
| smallUrl | The URL for the small sized image (240px on longest side) |
| mediumUrl | The URL for the medium sized image (500px on longest side) |
| largeUrl | The URL for the large sized image (1024px on longest side) |
| originalUrl | The URL for the originally uploaded image - returns an empty string if we don’t know the format of the original image. |
| contextUrl | The URL for this photo within the context of the photostream e.g. |
| contextThumbUrl | The URL for this photo’s thumbnail image within some sort of context e.g. |
| contextPhotoPrevious | The previous photo in this context (as returned by Flashr.photosGetContext) |
| contextPhotoNext | The next photo in this context (as returned by Flashr.photosGetContext) |
| contextCount | Not documented on flickr.com but maybe the number of photos in this context (e.g. |
| _contextPhotosets | Stores information about this Photos context in given Photosets |
| _contextGroupPool | Stores information about this Photos context in given Groups |
| _photosets | An Array containing references to the Photosets that this Photo is in. |
| _groups | An Array containing references to the Groups that this Photo is in. |
| exifData | The EXIF/TIFF/GPS tags associated with this photo. |
| _photos | A private static Object containing Photo objects. |
| Photo | Private constructor function - creates a new Photo object. |
| getComments | Returns an Array of all the Comments left on this Photo. |
| _addComment | Private internal function - Adds a Comment object to this Photo. |
| getNotes | Returns an object containing all the note’s that have been left on this Photo |
| _addNote | Private internal function - adds a Note object to this Photo. |
| _removeNote | Private internal function - removes the reference to the given Note from this Photo so that the Note object can be sucessfully garbage collected. |
| getTags | Returns an object containing all the tags’s that are associated with this Photo. |
| getTagsAsStrings | A utility function to get all the Tag’s associated with this Photo as Strings. |
| _addTag | Private internal function - adds a Tag object to this Photo and associates it with a Person who is the Person who associated that Tag with this Photo. |
| _setTagsAsStrings | Private internal function - set’s this Photo’s _tags... |
| _addPhotoset | Private internal function - adds a photoset to this Photos _photosets Array |
| _removePhotoset | Private internal function - removes a given Photoset from this Photos _photosets Array. |
| getPhotosets | This Photos _photosets Array. |
| _addGroup | Private internal function - adds a Group to this Photos _groups Array |
| _removeGroup | Private internal function - removes a given Group from this Photos _groups Array. |
| getGroups | This Groups _groups Array. |
| _setContextPhotoset | Private internal function - adds information about this Photos context in a given Photoset |
| getContextPhotoset | Get information about the context of this Photo in a given Photoset |
| _setContextGroupPool | Private internal function - adds information about this Photos context in a given Group |
| getContextGroupPool | Get information about the context of this Photo in a given Photoset |
| _addSize | Private internal function - adds a PhotoSize object to this Photo. |
| getSizes | Get’s information about the available PhotoSizes for this Photo (assuming Flashr.photosGetSizes has been called - otherwise returns an empty Array). |
| getLargestAvailableSize | Use to get the biggest available version of this Photo. |
| _destroy | Private function to remove this Photo object from the _photos Array so that it can’t be used again. |
| getPhoto | Get’s a Photo object for the given photo ID. |
public var owner: Person
A reference to the Person who owns this photo.
public var originalFormat: String
The format that this Photo was originally uploaded in.
var geoPerms: GeoPerms
GeoPerms describing who may view geo data for a photo.
private var _dateUploaded: Date
The date this photo was uploaded
You set this as a String which the setter method automagically transforms from a UNIX Timestamp (as provided by flickr.com) to a Date object.
private var _dateTaken: Date
The date this photo was taken.
You set this as a string which the setter method automagically transforms from a MySQL Timestamp (as provided by flickr.com) to a Date object.
private var _dateUpdated: Date
The date this photo was updated
You set this as a String which the setter method automagically transforms from a UNIX Timestamp (as provided by flickr.com) to a Date object.
private var _photoPageUrl: String
The link to this photo’s page on flickr.com. If flickr.photos.getInfo has been called on this photo then the link will be the “pretty” one with the user’s chosen screen name. Otherwise it will be the “ugly” one which works just as well but doesn’t look as good.
public var location: GeoLocation
The GeoLocation of this Photo. This will be filled on a call to Flashr.photosGetInfo or to any method call which had “geo” passed in it’s “extras” parameter.
public function get smallSquareUrl():String
The URL for the small square (75x75 pixels) version of this Photo
private var _thumbnailUrl: String
DEPRECATED This is the 75 x 75 pixel thumbnail image refered to as “small square” in the flickr.com documentation. The prefered way to refer to this image is using smallSquareUrl which is more accurately named and will remain in future versions of Flashr. It is not to be confused with the 100 pixels on the longest side image called “thumbnail” in the flickr.com documentation (and called thumbUrl here)
public function set thumbUrl( smallUrl: String )
The URL for the thumbUrl image (100px on longest side) NOTE - this is referred to the “thumbnail” image on flickr.com but for historical reasons it is known as thumbUrl here (thumbnailUrl points to smallSquareUrl)
public function set smallUrl( smallUrl: String )
The URL for the small sized image (240px on longest side)
public function set mediumUrl( mediumUrl: String )
The URL for the medium sized image (500px on longest side)
public function set largeUrl( largeUrl: String )
The URL for the large sized image (1024px on longest side)
This image only exists where the originally uploaded image is of sufficient size - your code should be able to deal with the image not existing
private var _originalUrl: String
The URL for the originally uploaded image - returns an empty string if we don’t know the format of the original image.
If this method returns an empty string you should do one of the following:
public var contextUrl: String
The URL for this photo within the context of the photostream e.g. as returned from a call to flickr.photo.getContext
public var contextThumbUrl: String
The URL for this photo’s thumbnail image within some sort of context e.g. as returned from a call to flickr.photo.getContext TODO: The thumbnail URL should be independant of context, no?
public var contextPhotoPrevious: Photo
The previous photo in this context (as returned by Flashr.photosGetContext)
public var contextPhotoNext: Photo
The next photo in this context (as returned by Flashr.photosGetContext)
public var contextCount: Number
Not documented on flickr.com but maybe the number of photos in this context (e.g. the user’s photostream)? (as returned by Flashr.photosGetContext)
private var _contextPhotosets: Object
Stores information about this Photos context in given Photosets
Flashr.photosetsGetContext, getContextPhotoset, _setContextPhotoset
private var _contextGroupPools: Object
Stores information about this Photos context in given Groups
Flashr.groupsPoolsGetContext, getContextGroupPool, _setContextGroupPool
private var _photosets: Array
An Array containing references to the Photosets that this Photo is in. Filled in by a call to Flashr.photosGetAllContexts and also when you e.g. add a Photo to a Photoset through Flashr.photosetsAddPhoto or Flashr.photosetsEditPhotos (via Photoset._addPhoto)
private var _groups: Array
An Array containing references to the Groups that this Photo is in. Filled in by a call to Flashr.photosGetAllContexts and also when you e.g. add a Photo to a Group through Flashr.groupsPoolsGetPhotos (via Group._addPhoto)
public var exifData: Array
The EXIF/TIFF/GPS tags associated with this photo. It is an Array of ExifData objects.
private function Photo( id: String )
Private constructor function - creates a new Photo object. Should be called via Photo.getPhoto.
function getComments():Array
Returns an Array of all the Comments left on this Photo. Will return an empty Array until Flashr.photosCommentsGetList or Flashr.photosCommentsAddComment has been called.
If Flashr.photosGetInfo has been called and Flashr.photosCommentsGetList hasn’t then we know the number of comments there should be and so can raise a warning to remind the user that they should have called Flashr.photosCommentsGetList
All the Comments that have been left on this Photo
private function _addComment( comment: Comment ):Void
Private internal function - Adds a Comment object to this Photo. If you want to do this you are probably looking for Flashr.photosCommentsAddComment
| note | The Note you want to add to this photo |
function getNotes():Object
Returns an object containing all the note’s that have been left on this Photo
All the Note’s that have been left on this Photo
private function _addNote( note: Note ):Void
Private internal function - adds a Note object to this Photo. If you want to do this you are probably looking for Flashr.photosNotesAdd
| note | The Note you want to add to this photo |
private function _removeNote( noteId: String )
Private internal function - removes the reference to the given Note from this Photo so that the Note object can be sucessfully garbage collected. Private because it should only be used internally by the library on a sucessful response from Flashr.photosNotesDelete,
| noteId | The id of the Note that is being deleted. |
function getTags():Object
Returns an object containing all the tags’s that are associated with this Photo.
All the Tag’s that are associated with this Photo. Each Tag is associated with a Person as well – the Person who left this Tag on this Photo. Each Tag is also associated with an id – this is the number you would use to call Flashr.photosRemoveTag if you wanted to remove that Tag from this Photo.
function getTagsAsStrings():Array
A utility function to get all the Tag’s associated with this Photo as Strings. Use this in cases where you don’t care about the details of the Tag or it’s relationship to this Photo (e.g. you aren’t planning to modify it or delete it) and you just want to know what it is...
An Array containing the clean version of the text for each Tag left on this Photo. NOTE: this is only useful to you if you are only interested in the textual content of these Tags (otherwise use getTags) and will only be filled after a call to Flashr.photosGetInfo for this Photo.
private function _addTag( id: String, tag: Tag, author: Person ):Void
Private internal function - adds a Tag object to this Photo and associates it with a Person who is the Person who associated that Tag with this Photo. If you want to do this you are probably looking for Flashr.photosAddTags
| id | The id which describes the link between this Photo and Tag. |
| tag | The Tag you want to add to this photo. |
| author | The Person who attached that Tag to this Photo. |
private function _setTagsAsStrings( tags: String, author: Person )
Private internal function - set’s this Photo’s _tags... This method is called when you supply “tags” to any method that takes an “extras” argument. In this case we get the list of tags returned to us without any corresponding information about the authors of the tags or the ids linking them to the Photo.
| tags | The tags to add to this photo as a space seperated string |
| author | The Person who added these tags (leave undefined if you don’t know) |
We don’t know the id’s that will associate the Tag’s with the Photos at this point so are using garbage ones. This means that you won’t be able to remove the tags using those ids... If you ever see a tag linked to a photo with an id starting with an underscore you know that this is not a real id and you need to call Flashr.photosGetInfo to get an id you can use with Flashr.photosRemoveTag
private function _addPhotoset( photoset: Photoset )
Private internal function - adds a photoset to this Photos _photosets Array
| photoset | The Photoset to add to this Photo. |
private function _removePhotoset( photoset: Photoset )
Private internal function - removes a given Photoset from this Photos _photosets Array.
| photoset | The Photoset to remove from this Photo. |
private function _setContextPhotoset( photosetId: Number, previousPhoto: Photo, nextPhoto: Photo )
Private internal function - adds information about this Photos context in a given Photoset
| photosetId | The id of the Photoset this context is for |
| previousPhoto | The Photo before this Photo in this context or undefined if this is the first Photo in this context. |
| nextPhoto | The Photo after this Photo in this context or undefined if this is the last Photo in this context. |
function getContextPhotoset( photosetId: Number )
Get information about the context of this Photo in a given Photoset
| photosetId | The id of the Photoset you want the context information for. |
An object containing nextPhoto and previousPhoto which are Photo objects. undefined if there is no information about this Photos context in the requested Photoset
private function _setContextGroupPool( groupId: String, previousPhoto: Photo, nextPhoto: Photo )
Private internal function - adds information about this Photos context in a given Group
| groupId | The id of the Group this context is for |
| previousPhoto | The Photo before this Photo in this context or undefined if this is the first Photo in this context. |
| nextPhoto | The Photo after this Photo in this context or undefined if this is the last Photo in this context. |
function getContextGroupPool( groupId: Number )
Get information about the context of this Photo in a given Photoset
| groupId | The id of the Group you want the context information for. |
An object containing nextPhoto and previousPhoto which are Photo objects. undefined if there is no information about this Photos context in the requested Group
function getSizes():Array
Get’s information about the available PhotoSizes for this Photo (assuming Flashr.photosGetSizes has been called - otherwise returns an empty Array).
Flashr.photosGetSizes, getLargestAvailableSize, _sizes
Returns : The _sizes Array.
function getLargestAvailableSize( maxDimension: Number ):PhotoSize
Use to get the biggest available version of this Photo. Call after Flashr.photosGetSizes has been called, otherwise logs an error message and returns null.
| maxDimension | Optionally the biggest size you want. e.g. if you want a version of this Photo which is up to but no more than 900 pixels high or wide you would 900 to this function. |
Returns : The PhotoSize object representing the largest available image (whose max dimension is less than or equal to the maxDimension parameter if passed)
private function _destroy()
Private function to remove this Photo object from the _photos Array so that it can’t be used again. Called internally on a successful call to Flashr.photosDelete
public static function getPhoto( photoId: String ):Photo
Get’s a Photo object for the given photo ID.
Consults _photos to make sure that only one Photo instance is created for each photo ID from flickr.com
| photoId | The id of the Photo you want to get |
The Photo object for the given id or false if that photo has been deleted using Flashr.photosDelete
This photo’s id.
public var id: String
A reference to the Person who owns this photo.
public var owner: Person
This photo’s secret.
public var secret: String
This photo’s server.
public var server: Number
This photo’s farm.
public var farm: Number
The format that this Photo was originally uploaded in.
public var originalFormat: String
Private constructor function - creates a new Photo object.
private function Photo( id: String )
This photo’s title.
public var title: String
This photo’s description.
public var description: String
The number of comments this photo has.
public var numComments: Number
The Comments that have been left on this Photo.
private var _comments: Array
The Notes that have been left on this photo.
private var _notes: Object
The Tags that are associated with this photo.
private var _tags: Object
The PhotoSizes that are associated with this photo.
private var _sizes: Array
Whether or not this photo is public.
public var isPublic: Boolean
Whether or not this photo is by a friend.
public var isFriend: Boolean
Whether or not this photo is by a family member.
public var isFamily: Boolean
GeoPerms describing who may view geo data for a photo.
var geoPerms: GeoPerms
The date this photo was uploaded
private var _dateUploaded: Date
The date this photo was taken.
private var _dateTaken: Date
The date this photo was updated
private var _dateUpdated: Date
The License for this Photo.
public var license: License
public var rotation: Number
The link to this photo’s page on flickr.com.
private var _photoPageUrl: String
The GeoLocation of this Photo.
public var location: GeoLocation
The URL for the small square (75x75 pixels) version of this Photo
public function get smallSquareUrl():String
DEPRECATED This is the 75 x 75 pixel thumbnail image refered to as “small square” in the flickr.com documentation.
private var _thumbnailUrl: String
The URL for the thumbUrl image (100px on longest side) NOTE - this is referred to the “thumbnail” image on flickr.com but for historical reasons it is known as thumbUrl here (thumbnailUrl points to smallSquareUrl)
public function set thumbUrl( smallUrl: String )
The URL for the small sized image (240px on longest side)
public function set smallUrl( smallUrl: String )
The URL for the medium sized image (500px on longest side)
public function set mediumUrl( mediumUrl: String )
The URL for the large sized image (1024px on longest side)
public function set largeUrl( largeUrl: String )
The URL for the originally uploaded image - returns an empty string if we don’t know the format of the original image.
private var _originalUrl: String
The URL for this photo within the context of the photostream e.g.
public var contextUrl: String
The URL for this photo’s thumbnail image within some sort of context e.g.
public var contextThumbUrl: String
The previous photo in this context (as returned by Flashr.photosGetContext)
public var contextPhotoPrevious: Photo
Calls flickr.photos.getContext to return next and previous photos for a photo in a photostream.
function photosGetContext ( photoId: String ):FlashrRequest
The next photo in this context (as returned by Flashr.photosGetContext)
public var contextPhotoNext: Photo
Not documented on flickr.com but maybe the number of photos in this context (e.g.
public var contextCount: Number
Stores information about this Photos context in given Photosets
private var _contextPhotosets: Object
Stores information about this Photos context in given Groups
private var _contextGroupPools: Object
An Array containing references to the Photosets that this Photo is in.
private var _photosets: Array
An Array containing references to the Groups that this Photo is in.
private var _groups: Array
The EXIF/TIFF/GPS tags associated with this photo.
public var exifData: Array
A private static Object containing Photo objects.
private static var _photos: Object
Returns an Array of all the Comments left on this Photo.
function getComments():Array
Private internal function - Adds a Comment object to this Photo.
private function _addComment( comment: Comment ):Void
Returns an object containing all the note’s that have been left on this Photo
function getNotes():Object
Private internal function - adds a Note object to this Photo.
private function _addNote( note: Note ):Void
Private internal function - removes the reference to the given Note from this Photo so that the Note object can be sucessfully garbage collected.
private function _removeNote( noteId: String )
Returns an object containing all the tags’s that are associated with this Photo.
function getTags():Object
A utility function to get all the Tag’s associated with this Photo as Strings.
function getTagsAsStrings():Array
Private internal function - adds a Tag object to this Photo and associates it with a Person who is the Person who associated that Tag with this Photo.
private function _addTag( id: String, tag: Tag, author: Person ):Void
Private internal function - set’s this Photo’s _tags...
private function _setTagsAsStrings( tags: String, author: Person )
Private internal function - adds a photoset to this Photos _photosets Array
private function _addPhotoset( photoset: Photoset )
Private internal function - removes a given Photoset from this Photos _photosets Array.
private function _removePhotoset( photoset: Photoset )
This Photos _photosets Array.
function getPhotosets():Array
Private internal function - adds a Group to this Photos _groups Array
private function _addGroup( group: Group )
Private internal function - removes a given Group from this Photos _groups Array.
private function _removeGroup( group: Group )
This Groups _groups Array.
function getGroups():Array
Private internal function - adds information about this Photos context in a given Photoset
private function _setContextPhotoset( photosetId: Number, previousPhoto: Photo, nextPhoto: Photo )
Get information about the context of this Photo in a given Photoset
function getContextPhotoset( photosetId: Number )
Private internal function - adds information about this Photos context in a given Group
private function _setContextGroupPool( groupId: String, previousPhoto: Photo, nextPhoto: Photo )
Get information about the context of this Photo in a given Photoset
function getContextGroupPool( groupId: Number )
Private internal function - adds a PhotoSize object to this Photo.
private function _addSize( size: PhotoSize ):Void
Get’s information about the available PhotoSizes for this Photo (assuming Flashr.photosGetSizes has been called - otherwise returns an empty Array).
function getSizes():Array
Calls flickr.photos.getRecent to get the available sizes for a photo.
function photosGetSizes ( photoId: String ):FlashrRequest
Use to get the biggest available version of this Photo.
function getLargestAvailableSize( maxDimension: Number ):PhotoSize
Private function to remove this Photo object from the _photos Array so that it can’t be used again.
private function _destroy()
Get’s a Photo object for the given photo ID.
public static function getPhoto( photoId: String ):Photo
Fetches a list of availabale photo licenses for Flickr
function photosLicensesGetInfo():FlashrRequest
Calls flickr.photos.getInfo to get information about a Photo.
function photosGetInfo ( photoId: String, secret: String ):FlashrRequest
Returns next and previous photos for a photo in a set.
function photosetsGetContext( photoId: String, photosetId: String ):FlashrRequest
Gets next and previous photos for a photo in a group pool.
function groupsPoolsGetContext( photoId: String, groupId: String ):FlashrRequest
Returns all visble sets and pools the photo belongs to.
function photosGetAllContexts( photoId: String ):FlashrRequest
Add a photo to the end of an existing photoset.
function photosetsAddPhoto( photosetId: String, photoId: String ):FlashrRequest
Modify the photos in a photoset.
function photosetsEditPhotos( photosetId: String, primaryPhotoId: Number, photoIds: Array ):FlashrRequest
Private internal function - adds a Photo to the end of this Photoset’s _photos array and updates numPhotos Called internally on a successful response from flickr.photosets.addPhoto.
private function _addPhoto( photo: Photo )
Gets a list of pool photos for a given group, based on the permissions of the group and the user logged in (if any).
function groupsPoolsGetPhotos( groupId: String, tags: String, extras: String, perPage: Number, page: Number, userId: String ):FlashrRequest
Private internal function - adds a Photo to this Groups _pool.
private function _addPhoto( photo: Photo )
Calls flickr.photos.getExif to return a list of EXIF/TIFF/GPS tags for a given Photo.
function photosGetExif ( photoId: String, secret: String ):FlashrRequest
Calls flickr.photos.comments.getList to get the comments for a photo.
function photosCommentsGetList ( photoId: String ):FlashrRequest
Calls flickr.photos.comments.addComment to add a comment to a photo as the currently authenticated user (authUser).
function photosCommentsAddComment( photoId: String, comment: String ):FlashrRequest
Add a Note to a Photo.
function photosNotesAdd( photoId: String, noteX: Number, noteY: Number, noteW: Number, noteH: Number, noteText: String )
Delete a Note from a Photo.
function photosNotesDelete( noteId: String )
Calls flickr.photos.removeTag to remove a tag from a photo.
function photosRemoveTag ( tagId: Number ):FlashrRequest
Calls flickr.photos.addTags to add tags to a given photo.
function photosAddTags ( photoId: String, tags: String ):FlashrRequest
Calls flickr.photos.addTags to delete a photo from flickr.
function photosDelete ( photoId: String ):FlashrRequest