Text 7 Nov 8 notes Build a powerful Flickr Gallery with Rails and js

If you are using Rails and you need a flickr gallery just bear in mind these two things:

- Flickraw gem
- Galleria plugin

With the first one you need just to add it to your site:

FlickRaw.api_key = 'YOUR_API_KEY'
FlickRaw.shared_secret = 'YOUR_FLICKR_SECRET'
    
flickr = FlickRaw::Flickr.new
And using the complete flickr api, you can use, for example:
@photo_sets = flickr.photosets.getList(:user_id => "USER_ID")
And with Galleria, you could get everything that you want: Ruby code:
<div id="gallery">
    <% @photo_sets.each do |set| %>
      <div id="<%= set.id %>" class="photo_set"></div>
    <% end %>
</div>
Javascript code:
// if you have severals, you can do it with an each loop
var set_id = $('#gallery').children('.photo_set').attr('id');
      
      $('#gallery').children('.photo_set').galleria({
        flickr: 'set:'+set_id,
          flickrOptions: {
            sort: 'date-posted-asc'
          }
      });
P.S.: I wrote a simple example, starting here you can everything that you can imagine, ;)

  1. rabarroso posted this

Design crafted by Prashanth Kamalakanthan. Powered by Tumblr.