1. Skip to navigation
  2. Skip to content

The ELC Community Blog

A knowledge exchange on Ruby on Rails and Agile Development


Mephisto Flickr AJAX Loader

by stevend on December 01, 2007

I'm tired of waiting for my blog to load because of a slow flickr feed request! I designed this new plugin by copying the flickr photostream plugin, but making it actually load the pictures and the feed through an immediate AJAX request. This tremendously increased the performance of my mephisto pages!

The plugin defines a flickr controller, which accepts the AJAX request. Unfortunately, you can't change how the photos are laid out anymore (I'm not setting up a liquid context for this ajax response). Of course, if you don't like the result of the plugin, just change it to match what you want:

class FlickrController < ActionController::Base
  def index
    result = ""
    pics = find_pictures
    pics.each do |pic|
      result << "<a href='#{pic.link}'><img src='#{pic.send(params[:format].to_sym)}' alt='#{pic.title}'></a>"
    end

    render :inline => result
  end
end

How to install and use

  • Uninstall the flickr photostream plugin
  •    1  ./script/plugin install http://wush.net/svn/public/plugins/mephisto/mephisto_flickr_ajax
    
  • Use the following tag in your liquid template:
       1  {{flickrajaxphotostream feed:<your_feed_url> count:</your_feed_url><number_images> format:<[square, small, etc]>}}<br />
       2  {{endflickrajaxphotostream}}
       3  </number_images>
    
  • Also posted on flouri.sh

Comments

Add a comment


home | services | Ruby on Rails Development | code | blog | company