photo reference library: downloading flickr

After much trouble & research, I finally have an easy way to import images from the web & download any original image from flickr.

One of the features I wanted most for my locally stored photo reference library was to be able to bookmark images on the web, and download them locally. Also, I really wanted to be able to just grab any of my photosets on Flickr, and also store those locally, tags and all. Also, I wanted to be able to use imagecache & lightbox with these images.

Finally, after much futzing around with Drupal - I figured out how to do this.

New ingredients:
* get rid of emfield - it is a pain to theme
* make image url field (just a simple link field)
* add theme function for that link field (could be turned into little themeing module) which downloads the image in a given link field to a certain folder in files directory. Currently I am just pointing at a custom directory in files...settings could be added to map a field to a folder. There have been some attempts at this in drupal code - nothing conclusive, however this functionality is supposed to be a feature of the new image module in drupal 7.
* using feed api, feed element mapper, simple pie and feed api exhaustive parser, create content type for feeds
* note: i did try feed scraper, which has a tiny bit of documentation. basically you pick an element from a feed that feed api was able to parse (so if you are not seeing media:content, it is probably because your parsers can't read it.) then you map the scraper to a feed item. you write an XPath query (a way of searching xml tags) and it might be able to read the xml. For example, if you point to a description tag, you can search for an img like this: //img/@src -- http://www.w3schools.com/XPath/xpath_syntax.asp
* bookmark images (files, not webpages) with a given tag in del.icio.us (ex. 'mydownload') - grab the rss feed for that tag
* add delicious rss feed to feed api enabled content type (which is mapped to another content type for the feed item, which has link field)
* map deliciious original_url to cck image link field
* flickr: flickr produces two kinds of rss feeds, old and new. photosets are currently in the old format. however, if you append '&format=rss_200' to the feed, it will magically be converted to rss 2.0 -- which works fine with simple pie + feedapi exhaustive parser (note: i enabled both of these features at the same time, not 100% sure which one is responsible for enabling the media:content feed item - but that's the one you need, it creates the link to the original flickr image)
* added date field which maps to feed api build time, my recent images view is set to sort to that so any thing i add new shows up first (as opposed to some of my ancient flickr images, which show up last because they are old. this keeps the rss date for the node, but an internal date in the node for sorting.)

So, putting it all together... refreshing the feed content type makes it generate nodes for any element in the rss feed. When the node for the feed item is viewed, the theme (or eventually a field formatter) pulls the image from the web and saves it locally. Imagecache + lightbox are themed to the link, so in the view + node page you can pop any original image into lightbox. Also, all lightbox images are themed to be in the same group, so the next-back buttons will work.

Next steps

Once I clean up my download code & convert it to a module - I should be able to share it, the views and the content types - with a modules recipe. Then you can make your own Flickr Downloader & Web Images Manager.