EditResurrection

Finally took the old personal blog from d5 to d6 and gave it a face lift. The new Acquia Slate theme is pretty slick, but I wanted to give it just a small bit of uniqueness, so I wrote a little custom function into the theme in order to pull up random photos from one of my Flickr sets. It was fast and fun, made easy with the Flickr module's API. Here's a couple quick steps I took: <!--break-->

  1. Edited the page-front.tpl.php and inserted a little logic to give the #preface-wrapper a different background-image property.
    style="background-image: url(<?php print $flickr; ?>);"<?php endif; ?>>
  2. Wrote a custom function based off of the flickrblock.module's flickrblockphotosetrandom() function. The function returns just the flickr farm url instead of running through the theme functions.
    function acquiaslateflickrblockphotosetrandom($nsid, $shown, $size, $photosetid) {
      // Get information about the photoset, including the owner.
      $info = flickrphotosetgetinfo($photoset_id);
      if (!$info) {
        return;
      }

    // Get a list of "all" the photos in the photoset. This is cached. $response = flickrrequest('flickr.photosets.getPhotos', array( 'photosetid' => $photosetid, 'perpage' => 500, // get as many images as possible 'extras' => 'owner', ) ); if (!$response) { return; }

    // Randomly display $show_n of them $photos = $response['photoset']['photo']; shuffle($photos);

    $output = flickrphotoimg($photos[0], $size);

    return $output; }

  3. Set the result of this new function, called with hardcoded arguments, to a theme variable within template.php's phptemplatepreprocesspage() function.
      // get a flickr image for the front page background
      $vars['flickr'] = acquiaslateflickrblockphotosetrandom($nsid, $shown, $size, $photoset_id);
    

The one thing I couldn't find was a block setting when looking at the flickrblock.module for the large size picture, which I needed. But looking at how the url is created within flickr.inc's flickrphotoimg() function and comparing it with an actual large image on Flickr.com, I quickly saw that the size string is simply 'bd' for large.

Fun stuff!

comments powered by Disqus