Ursula's Digital Mixed-Media
Drupal 7 Instagram Feed

I wanted to add an Instagram feed to the Creative Clearinghouse site, and was struggling to find the right way to do it in Drupal. I searched all over and tried using the Drupagram module (it worked but not exactly what I needed), and started looking into the Feeds module. Then I stepped back and thought “Keep it Simple, Stupid”. One other time I had been searching for an answer to something I was trying to do in Drupal, and many searches later I had no results. It wasn’t that there were search results that were wrong or old or whatever, there was just a lack of search results from people complaining that they had an issue like I was perceiving I had. Until I realized the answer was so blatantly simple that a novice would even be able to figure it out. I was just waaaaaay overthinking it.

And so this time, I started thinking along those same lines. I probably was over thinking it. All I wanted to do was get some Instagram pictures that were hash tagged with #creativeclearinghouse. There is an RSS feed from Instagram that does that. There is an Aggregator module in Drupal 7 that pulls in feeds. So I gave that a whirl. It worked with views and presto, I had my Instagram feed!

First I set up a feed under the Aggregator module configuration to the feed URL- http://instagram.com/tags/yyy/feed/recent.rsswhere yyy is a hashtag. Then I created a view that was created using an Aggregator feed type. Here is a great tutorial on how to do that – http://drupal.ucar.edu/forum/node/155 .

I ended up tweaking the Aggregator module. I know, I know this is NOT what you are supposed to do!!! However, I wanted to link back to the Instagram author and show the caption. These are not pulled in now by the Aggregator module. I wanted  the author to be set to the value of the media:credit tag and the description to be set to the media:title tag. so I added the following:

 

    // Resolve dc:creator tag as the item author if author tag is not set.
    if (empty($item[‘author’]) && empty($item[‘dc:creator’]) && !empty($item[‘media:credit’])) {
      $item[‘author’] = $item[‘media:credit’];
    }

 

after:

    // Resolve dc:creator tag as the item author if author tag is not set.
    if (empty($item[‘author’]) && !empty($item[‘dc:creator’])) {
      $item[‘author’] = $item[‘dc:creator’];
    }

 

Also after:

   }
    elseif (!empty($item[‘content’])) {
      $item[‘description’] = $item[‘content’];
    }

I added:

    elseif (!empty($item[‘media:title’])) {
      $item[‘description’] = $item[‘media:title’];
    }

   This was in the modules parser.inc file.

 

 

Update 6/5/2013:

 

I think what folks might be missing is this: in my view for the Aggregator View, I played around with the fields.

I have 5 fields:

Aggregator: Item ID (which I hide from display)
Aggregator: Author (which I used the option to rewrite the results)
Aggregator: Link (which I hide from display)
Aggregator: Title (which I hide from display)
Aggregator: Link (which I used the option to rewrite the results)
Aggregator: Body (which I used the option to rewrite the results)

For the Aggregator: Author field, I used the option to rewrite the results like so:

from [author]:

and I output the results as a link like so:
http://instagram.com/[author]

I checked off “external server” and “title text” was set to:
[author]

I set the Aggregator: Link field and the Aggregator: Title field to not display.

I added a second Aggregator: Link field and used the rewrite the results option with the following value:

<a href=”[link_1]”><img src=”[link_1]” width=”300px” /></a><br/>

and hid the results if empty.

For the Aggregator: Body field I also used rewriting and set the value to:

[description] <br/><br/>

Hope this helps!

Comments

Leave a Reply

nineteen − ten =