Menu

#5 Patch: Shortcut for "datetaken" attribute

open
nobody
None
5
2009-02-16
2009-02-16
No

When a flickr.photo.search includes "date_taken" in the "extras" attribute, the returned list already contains the "datetaken" attribute. The following patch makes it accessible to the getTakenDate() method, and saves massive number of API calls in certain scenarios.

Same would be possible for other attributes - i'm not confident about the internals of Phlickr - but the following patch works for me.

Would apply to other attributes as well, of course.

--- Photo.php.orig 2008-12-10 01:03:15.000000000 +0100
+++ Photo.php 2009-02-16 11:34:32.646767174 +0100
@@ -242,6 +242,11 @@
* @see getTakenGranularity(), getTakenTimestamp(), getPostedDate()
*/
public function getTakenDate() {
+ // if 'extras' includes 'date_taken' in a query, datetaken is
+ // available in the short version already as an attribute:
+ if (isset($this->_cachedXml->attributes()->datetaken)) {
+ return (string) $this->_cachedXml->attributes()->datetaken;
+ }
if (!isset($this->_cachedXml->dates['taken'])) {
$this->load();
}

Discussion


Log in to post a comment.