Flickr ImageField module

Recently we were asked to upgrade the FlickrUp module by Jose Reyero and Will White from Development Seed. The Stand Against Poverty website used FlickrUp last year when their site was built with Drupal 5 and they wanted this functionality again this year when their site was built on Drupal 6. So the original request was to upgrade the module to Drupal 6, but after poking around in the issue queue and checking out the module's usage statistics, it seemed that I was not going to get a whole lot of help. There is an issue for the upgrade already, but after reviewing the code, it became clear that there was a lot of functionality duplication that is already handled by ImageField and Flickr. So I set out to use some of the basic concepts from FlickrUp and see how I could utilize what was already there.

Admin

The Flickr administration page and the ImageField cck options forms are altered with hook_form_alter() and hook_help().

Flickr

Flickr already has an administration page that has some information that we need: the Flickr API Key, and the API Shared Secret which are given to you when you sign up for a API key from Flickr. However, since the goal of Flickr ImageField is to upload photos to your Flickr account, we need to make sure that we have a writable key, and for that we need an Authorization Token from Flickr.

Here are before and after pics of the Flickr administration pages:

I know it's a little hard to see from the help text, but once you input your key and secret, the token is automatically retrieved from Flickr for you. This is one of the helpful functions that is provided within the phpFlickr package. I simply modified the examples they provided by bootstrapping Drupal so I could access a few common functions, did a little variable_set() magic and va-va-voom! ...automatic token retrieval. This also requires that in your API key setup on Flickr that you define the callback function as described in the help that is provided. This simply points Flickr back to your site after you authorize.

ImageField

For the ImageField settings, I simply altered the content_field_edit_form and added a checkbox for the user to say that this is a field that when a photo is uploaded, that photo should also be uploaded to Flickr, using the settings from the Flickr admin.

I realized after the fact, that even though this is in the Global settings, which are applied to every field instance, Flickr ImageField does not respect this. It uses the content type name and field name combination in order to come up with a unique setting for each content type. What this means, is if you use this same field on another content type, you will still have to check off this box if you want the photos that are uploaded through this field to also be uploaded to your Flickr account.

Another little failsafe built into this setting, is that it checks for the authorization token before you can enable it. If the API, Secret or Token are not filled out, this box is disabled and you are presented with a link to your Flickr setting page in order to get that all setup first.

Location tokens

Before I forget, you may have also noticed that in the screenshot of the Flickr administration page, there is a field for Global Flickr tags. This is a field that will allow you to tag every photo that is uploaded through your site with a global tag, something like your site name would be appropriate here. But not only that, there was also the request when building this, that location information be tagged on here. Now, there are a few different methods for putting location information upon a node. Flickr ImageField supports two of the methods that are provided by the Location module: one being meta data right on the node object in $node->location and another being through a location cck field which is found on the node object at $node->field_location. The client had their location information actually within Taxonomy, so I hacked this in for them really quick but I could not come up with a quick way of making this a general use feature with the module, so excluded it from the release. If people find it useful, and it gains any sort of traction, I'm sure it will be resolved at some point.

See you next time!

// comments

  • Jerad Bitner's picture
  • Title
    Chief Technology Officer
    Bio

    Jerad is our co-founder and CTO, and has been using Drupal since the nightmare upgrades from 4.6 to 4.7 (that's early 2005, if you're asking). He started out as a Technical Illustrator with C/S Group and worked for three years with Photoshop, Illustrator, AutoCad and Macromedia products as well as PHP. When it came time to replicate a platform across the different locations of the company, Jerad found Drupal and hasn't looked back since.

    With 5 contributed modules and thousands of contributions to Drupal, he has gained many friends and an excellent standing within the community. He enjoys participation and helping out in any way he can, but enjoys learning most of all.

    Jerad has been on the teams at Sony BMG (now Sony Music Entertainment) and LifeTime Digital where he had the opportunities to work with some of the best minds in the Drupal community. Being a part of these awesome teams has helped lead him to where he is today. An avid reader, biker, hiker, and drummer, Jerad brings an energetic drive to the team and a wealth of knowledge that is helping lead them to more productive, satisfying lives.

// add comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <hr>
  • Lines and paragraphs break automatically.

More information about formatting options