Search code examples
jqueryapiflickr

Flickr Json different size


I'm building a custom widget for my site, fetching flickr photos. This code works fine, but I need to fetch the small size 320x240 instead of 240x180.

jQuery(document).ready(function($){
                $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?ids=<?php print $flickrid; ?>lang=en-us&format=json&jsoncallback=?", function(data){
                      $.each(data.items, function(index, item){
                            $("<img/>").attr("src", item.media.m).appendTo(".slides_container")
                      });
                    });
            });

It's currently fetching the "_m" size, what I need is the "_n", thank you.


Solution

  • Got this sorted easily, must of been tired last night.

    For anyone else looking for this, simply change

    ("src", item.media.m)
    

    to

    ("src", item.media.m.replace('_m', '_n'))
    

    _n being the size you wish to fetch.