Flickr API and cflickr - performance issue with my code.
I using cflickr to access the Flickr api and display photos in a lightbox. My code is working, but incredibly slow. I'm assuming that I'm going about it in an incorrect way and hoping someone can point out a better way to do what I'm trying to accomplish. My speed issues develop when I'm trying to extract the image descriptions within a loop that is outputing the images to the page.
Here is an example of the code that I'm using:
using the following to grab the photos:
<cfset photos = cflickr.photosets_getPhotos(photoset_id=72157624340881708 , auth_token=token) />
I am then using the following to loop through the array of photos and and also retrieve the description for each image.
<div style="width:423px; margin: auto;" id="gallery">
<cfloop from="1" to="#arraylen(photos.photoset.photo)#" index="i">
<cfset p = photos.photoset.photo />
<cfset img_desc = cflickr.photos_getInfo(photo_id=p.id).photo.description />
<cfset img_desc = replace(img_desc, 'TRIP', '<br />TRIP') />
<cfset title = photos.photoset.photo.title />
<cfset title = title & "<br />" & img_desc />
<cfoutput>
<a href="#cflickr.getPhotoUrl(p, '')#" title="#title#"><img src="#cflickr.getPhotoUrl(p, 's')#" /></a>
</cfoutput>
</cfloop>
</div>
The problem with the code is when it is making the request for img_desc inside of the loop to the Flickr api. Each instance of that call is taking on average 300 to 400ms and the array has over 300 items so it times out. Should I be retrieveing all of the image descritpions at once before the loop and if so how would I best link these with image data that they belong with? It seems like I'm going about this in a rather inefficient manner.
I was hoping that I could call a function that retrieved all of the data that I need in one call, but so far I've been unable to find that.
