0

I am following a tutorial to show flickr pictures when you search for a tag. I have followed the tutorial exactly the way it is and have even checked the jquery latest version to ensure it is pulling the info. But whenever I run the query, it does not display any pictures. Is there something I am missing as Im not sure what it is. Here is the code below

<link rel="stylesheet" type="text/css" href="scripts/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
    <script type="text/javascript" src="scripts/jquery.1.9.1.js"></script>
    <script type="text/javascript" src="scripts/fancybox/jquery.mousewheel-3.0.4.pack.js"></script>
    <script type="text/javascript" src="scripts/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
   <script type="text/javascript">
        function searchPics(yourKeywords) {

            $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",
            {
                lang    : 'en-us',
                tags    : yourKeywords,
                tagmode : 'all',
                limit   : '20',
                format  : 'json'
            },
            function(data){

                var imgInsert = "";
                var items = [];

                //create the element that holds the images
                $('<div/>', {
                    'id': 'content',
                    html: items.join('')
                }).appendTo('#wrapper2').insertAfter('#left_sidebar');

                /* each image loaded from flickr will have a div as parent then the main parent
                will apend to the wrapper */
                $.each(data.items, function(i,item){
                    if (i == 20) return false;
                    var imgThumb = item.media.m.split('m.jpg')[0] + 'm.jpg'; //size of the image small max 240px
                    var imgLarge = item.media.m.split('m.jpg')[0] + 'b.jpg'; //large size of the image for fancybox

                    imgInsert += '<div class="avatar">';
                    imgInsert += '<a href="' + imgLarge + '" rel="flickr_group" class="big_img" title="' + item.title + '">';
                    imgInsert += '<img title="' + item.title + '" src="' + imgThumb + '" alt="' + item.title + '" />';
                    imgInsert += '</a></div>';
                });
                var cachedItems = $(imgInsert).data('cached', imgInsert);

                $('#content').append(imgInsert).addClass(yourKeywords).data('cached', data.items);

                /* create a history list and insert it into the left sidebar */
                var listChached = '';
                listChached += '<div class="history_list">';
                listChached += '<a class="' + yourKeywords + '_chached" href="javascript:;">';
                listChached +=  yourKeywords + '</a></div>';

                $(listChached).appendTo('#left_sidebar').insertAfter('form');

                $('.' + yourKeywords + '_chached').click(function(){

                    /* if the content has items then remove them
                    and insert the chathed itmes */
                    if ( $('#content').length > 0 ) {  
                        $('#content').empty();
                        $('#content').html(cachedItems);

                        //open the images using fancybox for the cached images
                        $("a[rel=flickr_group]").fancybox({
                            'transitionIn': 'none',
                            'transitionOut': 'none',
                            'titlePosition': 'over',
                            'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
                                return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
                            }
                        });                             
                    }                        
                })

                //open the images using fancybox for the new search
                $("a[rel=flickr_group]").fancybox({
                    'transitionIn': 'none',
                    'transitionOut': 'none',
                    'titlePosition': 'over',
                    'titleFormat': function (title, currentArray, currentIndex, currentOpts) {
                        return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
                    }
                });                
            });
        }

        $(function(){
            $('.search_form').submit(function(){
                //if it has been a search allready remove the old content and replace it with the new search
                if ( $('#content').length > 0 ) {
                    $('#content').remove();
                }                        
                searchPics(document.getElementById('keywords').value );
                return false;
            })
        })
    </script>

Is the style sheet for the fancybox, do I need to actually create that? I am baffled and would really appreciate your help.

Thank you in advance

Jenny P
  • 17
  • 2
  • 7
  • You are using fancybox v1.3.4 and that version **doesn't work** with jQuery v1.9+ check http://stackoverflow.com/q/14344289/1055987 for more – JFK May 17 '13 at 20:44
  • Hi I decided to use Jquery v1.8.3 with the fancybox 1.3.4 but this does not work and when I changed to fancy box 2.1.4 with jquery v1.9+ it still did not display any pictures. I just do not know what the issue is, am I reading the stackoverflow thread wrong with all the compatible versions?. Please could you advise. – Jenny P May 17 '13 at 20:58
  • jQuery v1.8.3 with fancybox v1.3.4 -or- jQuery v1.9+ with Fancybox v2.1.4 are good combinations. what is the tutorial you said you were following? – JFK May 17 '13 at 21:31
  • The tutorial is searching for flickr photos using jquery and fancybox. The link is http://carst.me/2011/08/search-for-photos-using-jquery-flickr-api-and-fancybox-part-2/ – Jenny P May 17 '13 at 21:56

0 Answers0