Question

So I've got a hobby site I'm working on. I've got items that are tagged and I want to associate those items with photos from Flickr. Even with restrictive searches, I might get results numbering in the thousands.

Requirements:

  1. I want to display between 10-20 pictures but I want to randomize the photos each time.
  2. I don't want to hit Flickr every time a page request is made.
  3. Not every Flickr photo with the same tags as my item will be relevant.

How should I store that number of results and how would I determine which ones are relevant?

Was it helpful?

Solution

I would suggest moving the code that selects, randomizes, downloads and caches photos to separate service. It could be locally accessible REST application. Keep your core code clean and don't clutter it with remote operations and retention policy.

  1. Build tags-to-images map and store it locally, in file or database. Randomizing array is easy in both cases.
  2. Point image src to local cache. Clean cache periodically, depending on your hosting capacity.
  3. Whitelist or blacklist photos to filter them in step 1.

OTHER TIPS

Your best bet for parts 1 and 2 is to make a large request, say returning 100 or 200 photos and store the URL and other details. Then producing random selections from your local copy should be simple.

For part 3 I'm not sure how you would accomplish this without some form of human intervention, unless you can define 'relevant' in some terms you can program against.

If human intervention is fine then obviously they can browse your local copy of photos and pick relevant ones (or discard un-relevant ones).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top