Flickr Photo Gallery with Colorbox in jQuery
Last week I updated my Blogger site to be responsive and optimised the page load time. Whilst doing those optimisation, I was looking for a simple photo gallery to display the photos from my Flickr photo stream. I've tried flickr sideshow, pictobrowser and slideflickr however I was not satisfied with them. I then started to study the Flickr API and tried to make a Flickr-like justified layout for my photography page. While trying to code the jQuery plugin, I found two great articles by Sam from Wackylabs.net and Miro Mannino. Miro explained how the layout could be done with a detailed illustrations but I decided to use Sam's algorithm to build my own jQuery plugin.
The plugin loads 5 rows when scrolling to the end of the page until photos all are loaded. If the configuration specifies more than one page, then it calls and loads next page until it reaches maximum pages. The current solution is not perfect and may affect the performance when it loads more than 800 photos. I will be working on optimising the performance to allow loading more photos.
This jQuery plugin also uses Colorbox to show larger version of photos when user clicks on the photo.
Okay, let me explain the configuration and how to use the plugin. However feel free to jump straight to the demo to view-source.
The following example uses "flickr.photos.search" method to load photos with tag "canon". It shuffles loaded photos to randomly display photos. If you want to display your photo stream, you should add "user_id" to params and change the method to "flickr.people.getPhotos".
You can see it in action at below or from here. You can also read and study the plugin from here.
The plugin loads 5 rows when scrolling to the end of the page until photos all are loaded. If the configuration specifies more than one page, then it calls and loads next page until it reaches maximum pages. The current solution is not perfect and may affect the performance when it loads more than 800 photos. I will be working on optimising the performance to allow loading more photos.
This jQuery plugin also uses Colorbox to show larger version of photos when user clicks on the photo.
Okay, let me explain the configuration and how to use the plugin. However feel free to jump straight to the demo to view-source.
- rows: the total/initial rows to show (default to 5)
- rowHeight: the desired height of row (default to 150)
- borderWidth: the border width of each photo (default to 5)
- shuffle: shuffles the photo array when value is true (default to false)
- maxPage: the maximum flickr pages to load (default to 3)
- loadOnScroll: loads new photos when scrolling to page end (default to false)
- params->method: the Flick API method (default to 'flickr.photos.search')
- params->api_key: the API key which you can get it from here
- params->user_id: your user id for fetching your photo stream. You can get it from here
- params->per_page: the available photos per page from the results of API call (default to 100)
- params->page: the start page (default to 1)
- params->tags: the tag of photos to search (default to blank)
The following example uses "flickr.photos.search" method to load photos with tag "canon". It shuffles loaded photos to randomly display photos. If you want to display your photo stream, you should add "user_id" to params and change the method to "flickr.people.getPhotos".
You can see it in action at below or from here. You can also read and study the plugin from here.
Related Posts
In case you missed it
A short update from me
It has been a while since I post a blog page on Blogger which was created back in 2013. So I took an opportunity to...
Showcase the blog site elements
The standard paragraphs Welcome to this demo page! Here, you’ll get an exclusive preview of our cutting-edge platform designed to revolutionise your digital experience. Our...
Issue with "Don't track your own pageviews"
Do you use your own domain name with Blogger? Do you place “Blogger’s Stats Widget” on your page? Or do you regularly check up the...