GithubHelp home page GithubHelp logo

flimshaw / jquery-flickr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rpheath/jquery-flickr

0.0 3.0 0.0 111 KB

Implements (some of) the Flickr API using jQuery.

Home Page: http://rpheath.com

JavaScript 100.00%

jquery-flickr's Introduction

(Some of) the Flickr API in jQuery.

Sometimes all you need is a simple javascript interface to pull in Flickr photos.

Requirements

Your Flickr API key.

Why?

Because I love javascript. Also, because I had to solve this problem recently, and the current solutions were
too “not my style”. Most had a universal flickr() method that required the user to pass a string of the method
to be executed. I’d rather just call a method than explain what method to call. Which brings me into my next point…

Chaining

Something common to jQuery users is the ability to chain method calls. Well, I took that a step further when
designing out the plugin interface. Initially, the user calls flickr() on the jQuery object, which then makes all
of the supported Flickr API calls available, allowing the user to “chain” the API call directly to the flickr() object.
And the beauty is that the result of the API call will then return the original jQuery object, so you can continue
chaining on your merry way :-)

An example speaks a thousand words, I know…

$('#photos').flickr({api_key: 'xxx'}).getRecentPhotos({per_page: 2}).addClass('thumbnails')

// returns something like ...

<div id="photos" class="thumbnails">
  <ul class="flickr">
    <li>
      <a title="<image title>" href="http://www.flickr.com/photos/<user_id>/<photo_id>/">
        <img alt="<image title>" src="<square thumbnail url>"/>
      </a>
    </li>
    <li>
      <a title="<image title>" href="http://www.flickr.com/photos/<user_id>/<photo_id>/">
        <img alt="<image title>" src="<square thumbnail url>"/>
      </a>
    </li>
  </ul>
</div>

You can see how calling addClass() at the very end was pretty much the same as calling $('#photos').addClass() directly.
Again, the chained Flickr API call returns the original jQuery object.

Handling Sizes

If no link_to_size is specified in the configuration, the thumbnails will link back to flickr.

Available sizes include:

  • ‘sq’ // => square
  • ‘t’ // => thumbnail
  • ‘s’ // => small
  • ‘m’ // => medium

Any invalid size will default to ‘m’. You can also specify the thumbnail size in the same manner, but by passing a
thumbnail_size options to the flickr() method.

Examples

// common configuration
var config = {
  api_key: 'xxx',
  thumbnail_size: 'sq'
}

// recent public photos
$('#photos').flickr(config).photosGetRecent()

// recent 8 photos from a user's contacts
$('#photos').flickr(config).photosGetContactsPublicPhotos({user_id: 'xxx', per_page: 8})

// recent 10 photos from a user's stream
$('#photos').flickr(config).photosSearch({user_id: 'xxx', per_page: 10})

// recent 10 photos from a user's stream with the tag 'portfolio'
$('#photos').flickr(config).photosSearch({user_id: 'xxx', per_page: 10, tags: 'portfolio'})

// recent 10 photos from a particular photoset
$('#photoset').flickr(config).photosetsGetPhotos({photoset_id: '72157600185772527', per_page: 10})

You get the idea. All of the options listed on the Flickr API (for the supported methods)
are available. The photosSearch() method is by far the most useful – perfect for showing your photos on your blog or site.

License

© 2008 Ryan Heath, released under the MIT license

jquery-flickr's People

Contributors

rpheath avatar flimshaw avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.