Note that there are some explanatory texts on larger screens.

plurals
  1. POConstruct the URL from JSON feed
    primarykey
    data
    text
    <p>Could anyone please advise me of what am I doing wrong here?</p> <p>I am trying to construct the image URL but using the flickr.photos.search method now (I need to display images close to geolocation of the visitor), I had it working before with groups_pool.gne and the JSON feed was different (simpler) formatted but now..</p> <p>The URL is working, I get the array with all the data I need (farm, server, secret and id) but can't construct the url for the photo.</p> <pre><code>$.getJSON("http://api.flickr.com/services/rest/?method=flickr.photos.search&amp;api_\ key=KEY&amp;format=json&amp;privacy_filter=0&amp;media=photos&amp;has_geo=1&amp;accuracy=13&amp;sort=int\ erestingness-desc&amp;content_type=1&amp;per_page=32&amp;extras=geo,owner_name&amp;page=1&amp;radius\ _units=km&amp;radius=1.521739&amp;lat=40.952532&amp;lon=-4.1326349999999366&amp;text=Alcazar&amp;jso\ ncallback=jsonp1320163051486", getJSONimages); function getJSONimages(data) { var htmlString = ""; $.each(data.photos.photo, function(i,item){ htmlString += '&lt;img src="http://farm'+ item.farm +'.static.flickr.com/'+ item.server +'/'+ item.id +'_'+ item.secret +'_m.jpg" /&gt;'; }); $('#slideshow').html(htmlString); </code></pre> <p>Thank you.</p> <hr> <p>I have added the url_m in the extras, in the URL to get the JSON feed and I get the full URL in my feed and that should help as I do not have to concatenate the rest but still doesn't work.</p> <p>I can't get it to work, and it's extremely frustrating as I know is very simple. Well, not for me obviously.</p> <p>This is my function, after I get the url_m in the loop:</p> <pre><code>function getJSONimages(data) { var htmlString = ""; $.each(data.photos.photo, function(i,item){ // var url = (item.url_m).replace("\", ""); htmlString += '&lt;img src="' + item.url_m + '" /&gt;'; }); $('#slideshow').html(htmlString); } </code></pre> <p>Even if I use the "url" variable or no, same result.</p> <p>However, I have noticed something.</p> <p>In the feed using groups_pool.gne, where I am able to pull the photos successfully, I go to the media.m like that:</p> <pre><code>$.each(data.items, function(i,item){ var biggestSize = (item.media.m).replace("_m.jpg", ".jpg"); htmlString += '&lt;img src="' + biggestSize + '" /&gt;'; </code></pre> <p>Notice that I have items, then media, then m with it's own value! Is actually items.[media: {m:PHOTOURL}].</p> <p>Where as in this other JSON feed using the flickr.photos.search method, I have the following "object path": jsonFlickrApi.photos.photo[{url_m:PHOTOURL}]</p> <p>And try to use this loop:</p> <pre><code>$.each(data.photos.photo, function(i,item){ htmlString += '&lt;img src="' + item.url_m + '" /&gt;'; </code></pre> <p>I think this is my problem but I don't have any ideas <strong>how to approach</strong> it. It's obvious there is a different structure between the two feeds:</p> <p>items.[media: {m:PHOTOURL}] photos.photo[{url_m:PHOTOURL}]</p> <p>I am going to research more on jQuery loops. Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload