I must be missing something about the way the module (or flickr) wants to behave.

My usecase seems obvious:

1. I have lots of photos

2. They are neatly organised into sets for various reasons

3. On my drupal site I want to randomly display images from *a specified set*

None of the options in this module seem to point me to this simple, direct, solution...?

What am I missing?

CommentFileSizeAuthor
#5 flickr_block.random-photoset.patch3.73 KBlyricnz

Comments

Anonymous’s picture

Category: support » feature

If anyone else is interested in this feature request please subscribe

@boabjohn
Please consider writing this functionality and submitting a patch here for review

boabjohn’s picture

Howdy Paul,

Sorry, I'm not a coder at all. If it helps, here's a bit more explanation.

My context is that a community organisation uses a common Flickr account to share and organise their extensive photo collection. There are multiple contributors from various offices across the country. These people are communications officers.

On their organisational website, there are the usual thematic divisions to present content: here's our projects, here's our people, here's our partners... etc etc.

What we were expecting is that the Flickr module would allow us to drop a block instance into the sidebar at various points in the site, and then we could configure each block to pick up photos from an appropriate Flickr collection.

A friend wrote a once-off patch to get me to a single collection. I'll see if I can get him to post the code here for reference.

Cheers,

JB

lyricnz’s picture

Here's the code that I put in a custom block, to display a random photo from a specific photoset. The "theme function" at the start is a bit of a kludge - the code was experimental, so I didn't want to modify the theme. Of course, in a real block, most of this would be configurable. Enjoy!

function my_theme_flickr_photo($p, $size = NULL, $format = NULL, $attribs = NULL) {
  $img = flickr_img($p, $size, $attribs);
  $photo_url = flickr_photo_page_url($p['owner'], $p['id']);
  $title = is_array($p['title']) ? $p['title']['_content'] : $p['title'];
  return l($img, $photo_url, array('title' => $title), NULL, NULL, TRUE, TRUE);
}

    $sid = "72157610920004385"; // photoset id
    $photo_size = 't'; // s t m - b o

    drupal_add_css(drupal_get_path('module', 'flickr') .'/flickr.css');

    // Get a list of all photos in the photoset (this is cached)
    $res = flickr_request('flickr.photosets.getPhotos', array(
        'photoset_id' => $sid,
        'page' => 1,
        'per_page' => 500,
      )
    );

    // Display the image in the block
    $num = rand(0, count($res['photoset']['photo'])-1);
    $photo = $res['photoset']['photo'][$num];
    $photo['owner'] = $res['photoset']['owner'];
    print theme('flickr_photo', $photo, $photo_size, NULL, array('width' => '158', 'thickbox' => TRUE));

Edit: Update comments to match code.

Mathews_1’s picture

subscribe

lyricnz’s picture

Status: Active » Needs review
StatusFileSize
new3.73 KB

Here's a patch that creates a random-image-from-photoset block for Flickr 6.x-1.0-beta1

Anonymous’s picture

Version: 5.x-1.3 » 6.x-1.x-dev
Assigned: Unassigned »
Status: Needs review » Reviewed & tested by the community

Thanks for the work done here.

Ill get this work committed to the development branch either later today / tomorrow.

Best, Paul

Anonymous’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.