Permalink
Browse files

Merge branch 'fix-flickr-sizes'

  • Loading branch information...
phlipper committed Mar 24, 2010
2 parents 55559e2 + 416e29e commit e744ae81aa5f668a36a64e47e51b5c8c49cd4cf2
Showing with 17 additions and 27 deletions.
  1. +4 −0 CHANGELOG.md
  2. +3 −3 README.md
  3. +10 −24 jquery.fancy-photoset.js
View
@@ -1,5 +1,9 @@
# Fancy Photoset CHANGELOG
+## 0.3.0
+
+* Use URLs returned from the API rather than building them from scratch
+
## 0.2.0
* Add option to show only the first image in the set on the page
View
@@ -61,8 +61,8 @@ The plugin supports multiple photoset galleries per page:
* apiKey - Your Flickr API Key.
* photosetId - The ID of the photoset you want to load.
-* small - The smaller thumbnail version of the image to show. This corresponds to one of the following Flickr sizes: small, medium, large, original, thumbnail and square.
-* large - The larger version of the image link to and display in the Fancybox. This corresponds to one of the following Flickr sizes: small, medium, large, original, thumbnail and square.
+* small - The smaller thumbnail version of the image to show. This corresponds to one of the following Flickr sizes: square, thumbnail, small, medium and original.
+* large - The larger version of the image link to and display in the Fancybox. This corresponds to one of the following Flickr sizes: square, thumbnail, small, medium and original.
* captions - true or false: This will create a <span class="caption"> with the photo title if set to true.
* firstOnly - true or false: Setting true will only display the first image in the photoset on the webpage. All images will still be available to the Fancybox gallery.
@@ -72,7 +72,7 @@ See the demo.html file in the demo folder for an example of how to use the scrip
## Version
-The current version is 0.2.0
+The current version is 0.3.0
## License
View
@@ -2,15 +2,15 @@
* Dual licensed under the MIT (MIT_LICENSE.txt)
* and GPL Version 2 (GPL_LICENSE.txt) licenses.
*
- * Version: 0.2.0
+ * Version: 0.3.0
* Requires jQuery 1.4.2+, Fancybox 1.3.1+
* Docs: http://phlippers.net/code/fancy-photoset
*/
(function($) {
$.fn.fancyPhotoset = function(options) {
var opts = $.extend($.fn.fancyPhotoset.defaults, options);
var domId = 'fancyPhotoset-' + opts.photosetId;
- var jsonUrl = 'http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key={apiKey}&photoset_id={photosetId}&format=json&jsoncallback=?'.replace(/\{\w+\}/g, function(match) {
+ var jsonUrl = 'http://api.flickr.com/services/rest/?&method=flickr.photosets.getPhotos&api_key={apiKey}&photoset_id={photosetId}&extras=url_sq,url_t,url_s,url_m,url_o&format=json&jsoncallback=?'.replace(/\{\w+\}/g, function(match) {
return opts[match.replace(/\{|\}/g, '')];
});
@@ -44,30 +44,16 @@
// generate static image url
$.fn.fancyPhotoset.urlFor = function(photo, options) {
- var url = 'http://farm{farm}.static.flickr.com/{server}/{id}_{secret}{size}.{format}';
- var opts = $.extend({size: 'square', format: 'jpg'}, options);
- var sizes = {
- 'small' : '_m',
- 'original' : '_o',
- 'medium' : '',
- 'large' : '_b',
- 'thumbnail' : '_t',
- 'square' : '_s'
+ var opts = $.extend({size: 'square'}, options);
+ var urls = {
+ 'square' : photo.url_sq,
+ 'thumbnail' : photo.url_t,
+ 'small' : photo.url_s,
+ 'medium' : photo.url_m,
+ 'original' : photo.url_o
};
- return url.replace(/\{\w+\}/g, function(match) {
- match = match.replace(/\{|\}/g, '');
- switch (match) {
- case 'size':
- return sizes[opts.size];
- break;
- case 'format':
- return opts.format;
- break;
- default:
- return photo[match];
- }
- });
+ return urls[opts.size];
};
// default options

0 comments on commit e744ae8

Please sign in to comment.