diff --git a/block/flickr_block.module b/block/flickr_block.module
index fe4d3d7..307f1af 100644
--- a/block/flickr_block.module
+++ b/block/flickr_block.module
@@ -22,9 +22,9 @@ function flickr_block_help($path, $arg) {
  */
 function flickr_block_info() {
   // User blocks.
-  $blocks[0]['info'] = t("User recent Flickr photos");
+  $blocks[0]['info'] = t("User (node author) recent Flickr photos tagged as term from node");
   $blocks[1]['info'] = t("User recent Flickr photosets");
-  $blocks[2]['info'] = t("User random Flickr photos by term from node");
+  $blocks[2]['info'] = t("User (node author) random Flickr photos tagged as term from node");
 
   // Site wide blocks.
   $blocks[3]['info'] = t('Recent photos from a Flickr user');
@@ -178,12 +178,6 @@ function flickr_block_configure($delta = '') {
 
   // Build the block form - use unset to hide unwanted form elements.
   switch ($delta) {
-    // User recent Flickr photos.
-    case 0:
-      unset($form["flickr_block_{$delta}_user_id"]);
-      unset($form["flickr_block_{$delta}_group_id"]);
-      break;
-
     // User recent Flickr photosets.
     case 1:
       unset($form["flickr_block_{$delta}_user_id"]);
@@ -194,6 +188,7 @@ function flickr_block_configure($delta = '') {
       break;
 
     // User random Flickr photos.
+    case 0:
     case 2:
       unset($form["flickr_block_{$delta}_user_id"]);
       unset($form["flickr_block_{$delta}_group_id"]);
@@ -295,16 +290,6 @@ function flickr_shown_block_validate($element) {
  */
 function flickr_block_save($delta = '', $edit = array()) {
   switch ($delta) {
-    // User recent Flickr photos.
-    case 0:
-      variable_set('flickr_block_' . $delta, array(
-        'show_n' => (int) $edit["flickr_block_{$delta}_show_n"],
-        'size' => $edit["flickr_block_{$delta}_size"],
-        'media' => $edit["flickr_block_{$delta}_media"],
-      ));
-      cache_clear_all('flickr_block_' . $delta, 'cache', TRUE);
-      break;
-
     // User recent Flickr photosets.
     case 1:
       variable_set('flickr_block_' . $delta, array(
@@ -315,7 +300,8 @@ function flickr_block_save($delta = '', $edit = array()) {
       cache_clear_all('flickr_block_' . $delta, 'cache', TRUE);
       break;
 
-    // User random Flickr photos.
+    // User Flickr photos.
+    case 0:
     case 2:
       if (module_exists('taxonomy')) {
         variable_set('flickr_block_' . $delta, array(
@@ -596,22 +582,6 @@ function flickr_block_view($delta = '') {
           ),
         )) . ')' : '';
         switch ($delta) {
-          // User recent Flickr photos.
-          case 0:
-            $recent_photos = l(t('Recent Flickr @media', array('@media' => $media)), $people['photosurl'], array(
-              'attributes' => array(
-                'title' => t('View on Flickr.'),
-                'target' => '_blank',
-              ),
-            ));
-            $block['subject'] = t("!recent_photos by !username !map", array(
-              '!recent_photos' => $recent_photos,
-              '!username' => $people['name'],
-              '!map' => $map,
-            ));
-            $block['content'] = _flickr_block_recent($user->flickr['nsid'], $settings['show_n'], $settings['size'], $settings['media'], $delta, $people);
-            break;
-
           // User recent Flickr photosets.
           case 1:
             $recent_sets = l(t('Recent Flickr sets'), $people['photosurl'] . 'sets/', array(
@@ -624,9 +594,11 @@ function flickr_block_view($delta = '') {
             $block['content'] = _flickr_block_photosets($user->flickr['nsid'], $settings['show_n'], $settings['size'], $settings['media'], $delta);
             break;
 
-          // User random Flickr photos.
+          // User Flickr photos.
+          case 0:
           case 2:
-            $photos = l(t('Flickr @media', array('@media' => $media)), $people['photosurl'], array(
+            $recent = $delta == 2 ? '' : 'Recent ';
+            $photos = l(t('@recentFlickr @media', array('@recent' => $recent, '@media' => $media)), $people['photosurl'], array(
               'attributes' => array(
                 'title' => t('View Flickr photostream.'),
                 'target' => '_blank',
@@ -634,7 +606,7 @@ function flickr_block_view($delta = '') {
             ));
             // The used tags with a space forced after the comma and the last
             // one replaced by 'or'.
-            $tagged = (empty($tags)) ? '' : l(t("tagged <em>") . preg_replace('/(.*),/','$1 ' . t('or'),str_replace(',', ', ', $tags)) . "</em>", $people['photosurl'] . 'tags/' . $tags, array(
+            $tagged = (empty($tags)) ? '' : l(t("tagged <em>") . preg_replace('/(.*),/', '$1 ' . t('or'), str_replace(',', ', ', $tags)) . "</em>", $people['photosurl'] . 'tags/' . $tags, array(
               'attributes' => array(
                 'title' => t('View tagged photos on Flickr.'),
                 'target' => '_blank',
@@ -647,7 +619,8 @@ function flickr_block_view($delta = '') {
               '!username' => $people['name'],
               '!map' => $map,
             ));
-            $block['content'] = _flickr_block_tag_random($user->flickr['nsid'], $settings['show_n'], $settings['size'], $settings['media'], $tags, $delta, $people);
+            $random = $delta == 2 ? 1 : 0;
+            $block['content'] = _flickr_user($user->flickr['nsid'], $settings['show_n'], $settings['size'], $settings['media'], $tags, $delta, $people, $random);
             break;
 
         }
@@ -675,7 +648,7 @@ function flickr_block_view($delta = '') {
         '!username' => $people['name'],
         '!map' => $map,
       ));
-      $block['content'] = _flickr_block_recent($settings['user_id'], $settings['show_n'], $settings['size'], $settings['media'], $delta, $people);
+      $block['content'] = _flickr_user($settings['user_id'], $settings['show_n'], $settings['size'], $settings['media'], '', $delta, $people);
       break;
 
     // Recent photosets from a Flickr user.
@@ -713,7 +686,7 @@ function flickr_block_view($delta = '') {
         '!username' => $people['name'],
         '!map' => $map,
       ));
-      $block['content'] = _flickr_block_random($settings['user_id'], $settings['show_n'], $settings['size'], $settings['media'], $delta, $people);
+      $block['content'] = _flickr_user($settings['user_id'], $settings['show_n'], $settings['size'], $settings['media'], '', $delta, $people, 1);
       break;
 
     // Recent photos from a Flickr group.
@@ -737,7 +710,7 @@ function flickr_block_view($delta = '') {
         '!group' => $group,
         '!map' => $map,
       ));
-      $block['content'] = _flickr_block_group_recent($settings['group_id'], $settings['show_n'], $settings['size'], $settings['media'], $delta, $info['group']['pool_count']['_content']);
+      $block['content'] = _flickr_group($settings['group_id'], $settings['show_n'], $settings['size'], $settings['media'], '', $delta, $info['group']['pool_count']['_content']);
       break;
 
     // Random photos from a Flickr photoset.
@@ -763,7 +736,7 @@ function flickr_block_view($delta = '') {
         '!username' => $people['name'],
         '!map' => $map,
       ));
-      $block['content'] = _flickr_photoset_random($settings['user_id'], $settings['show_n'], $settings['size'], $settings['media'], $settings['photoset_id'], $delta);
+      $block['content'] = _flickr_photoset($info['owner'], $settings['show_n'], $settings['size'], $settings['media'], $settings['photoset_id'], $delta, 1);
       break;
 
     // Recent photos from a Flickr photoset.
@@ -789,7 +762,7 @@ function flickr_block_view($delta = '') {
         '!username' => $people['name'],
         '!map' => $map,
       ));
-      $block['content'] = _flickr_photoset_recent($settings['user_id'], $settings['show_n'], $settings['size'], $settings['media'], $settings['photoset_id'], $delta);
+      $block['content'] = _flickr_photoset($info['owner'], $settings['show_n'], $settings['size'], $settings['media'], $settings['photoset_id'], $delta);
       break;
 
     // Recent favorite public photos from a Flickr user.
@@ -826,7 +799,7 @@ function flickr_block_view($delta = '') {
         '!group' => $group,
         '!map' => $map,
       ));
-      $block['content'] = _flickr_block_group_random($settings['group_id'], $settings['show_n'], $settings['size'], $settings['media'], $delta, $info['group']['pool_count']['_content']);
+      $block['content'] = _flickr_group($settings['group_id'], $settings['show_n'], $settings['size'], $settings['media'], '', $delta, $info['group']['pool_count']['_content'], 1);
       break;
 
     // Random photos with a specific tag from a Flickr user.
@@ -835,7 +808,7 @@ function flickr_block_view($delta = '') {
       $media = $settings['media'] == 'videos' ? t('videos') : t('photos');
       // The used tags with a space forced after the comma and the last one
       // replaced by 'or'. In the link all whitespace is removed.
-      $tagged = l(t("Flickr @media tagged <em>", array('@media' => $media)) . preg_replace('/(.*),/','$1 ' . t('or'),preg_replace("/,([^\s])/", ", $1", $settings['tag'])) . "</em>", $people['photosurl'] . 'tags/' . $settings['tag'], array(
+      $tagged = l(t("Flickr @media tagged <em>", array('@media' => $media)) . preg_replace('/(.*),/', '$1 ' . t('or'), preg_replace("/,([^\s])/", ", $1", $settings['tag'])) . "</em>", $people['photosurl'] . 'tags/' . $settings['tag'], array(
         'attributes' => array(
           'title' => t('View tagged photos on Flickr.'),
           'target' => '_blank',
@@ -853,68 +826,13 @@ function flickr_block_view($delta = '') {
         '!tagged' => $tagged,
         '!map' => $map,
       ));
-      $block['content'] = _flickr_block_tag_random($settings['user_id'], $settings['show_n'], $settings['size'], $settings['media'], $settings['tag'], $delta, $people);
+      $block['content'] = _flickr_user($settings['user_id'], $settings['show_n'], $settings['size'], $settings['media'], $settings['tag'], $delta, $people, 1);
       break;
   }
   return $block;
 }
 
 /**
- * Recent block. Block delta: 0 and 3.
- */
-function _flickr_block_recent($nsid, $show_n, $size, $media, $delta, $people = NULL) {
-  if ($cache = cache_get('flickr_block_' . $delta . '_' . $nsid)) {
-    $output = $cache->data;
-  }
-  else {
-    switch ($size) {
-      case "x":
-        $output = theme('flickr_flickrcomslideshow', array(
-          'id' => $nsid,
-        ));
-        break;
-
-      case "y":
-        $output = theme('flickr_flickrcomslideshow_simple', array(
-          'id' => $nsid,
-        ));
-        break;
-
-      default:
-        $output = '';
-        if ($photos = flickr_photos_search($nsid, 1, array(
-          'per_page' => $show_n,
-          'media' => $media,
-        ))) {
-          $i = 0;
-          foreach ($photos['photo'] as $photo) {
-            $output .= theme('flickr_block_photo', array(
-              'photo' => $photo,
-              'size' => $size,
-            ));
-            $i++;
-          }
-          if ($i == 0) {
-            $output .= t('No media found !flickr.', array('!flickr' => $people['photostream']));
-            continue;
-          }
-          else {
-            // A counter if set to show.
-            $count = t('@number out of @total by !flickr', array(
-              '@number' => $i,
-              '@total' => number_format($people['count'], 0, ",", "."),
-              '!flickr' => $people['photostream'],
-            ));
-            $output .= variable_get('flickr_block_counter', 1) ? '<div class="flickr-counter">' . $count . '</div>' : '';
-          }
-        }
-    }
-    cache_set('flickr_block_' . $delta . '_' . $nsid, $output, 'cache', time() + (variable_get('flickr_block_refresh_others', 31) * 60 * 60));
-  }
-  return $output;
-}
-
-/**
  * Photoset block. Block delta: 1 and 4.
  */
 function _flickr_block_photosets($nsid, $show_n, $size, $media, $delta, $people = NULL) {
@@ -952,7 +870,7 @@ function _flickr_block_photosets($nsid, $show_n, $size, $media, $delta, $people
           break;
 
         default:
-          $output .= theme('flickr_block_photoset', array(
+          $output .= theme('flickr_photoset', array(
             'photoset' => $photosets[$i],
             'owner' => $nsid,
             'size' => $size,
@@ -975,7 +893,7 @@ function _flickr_block_photosets($nsid, $show_n, $size, $media, $delta, $people
       $output .= '</div>';
     }
     if ($i == 0) {
-      $flickr = l(t("on Flickr"), $people['photosurl'] . '/sets/', array(
+      $flickr = l(t("on Flickr"), $people['photosurl'] . 'sets/', array(
         'attributes' => array(
           'title' => t('View sets on Flickr.'),
           'target' => '_blank',
@@ -991,251 +909,6 @@ function _flickr_block_photosets($nsid, $show_n, $size, $media, $delta, $people
 }
 
 /**
- * Random from user block. Block delta: 5.
- */
-function _flickr_block_random($nsid, $show_n, $size, $media, $delta, $people = NULL) {
-  if ($cache = cache_get('flickr_block_' . $delta . '_' . $nsid)) {
-    $output = $cache->data;
-  }
-  else {
-    switch ($size) {
-      case "x":
-        $output = theme('flickr_flickrcomslideshow', array(
-          'id' => $nsid,
-        ));
-        drupal_set_message(t("Note that slideshows don't show in random but in reverse chronological order."), 'warning');
-        break;
-
-      case "y":
-        $output = theme('flickr_flickrcomslideshow_simple', array(
-          'id' => $nsid,
-        ));
-        drupal_set_message(t("Note that slideshows don't show in random but in reverse chronological order."), 'warning');
-        break;
-
-      default:
-        $output = '';
-        $random_photos = array();
-        if ($photos = flickr_photos_search($nsid, 1, array(
-          'per_page' => 500,
-          'media' => $media,
-        ))) {
-          $page_count = $photos['pages'];
-          // Do not try to return more than the total number of photos.
-          $to = min($show_n, $photos['total']);
-          for ($i = 0; $i < $to; $i++) {
-            sleep(0.125);
-            // Request a random page.
-            $photos = flickr_photos_search($nsid, rand(1, $page_count), array(
-              'per_page' => 500,
-              'media' => $media,
-            ));
-            // Select a random photo.
-            $index = rand(0, count($photos['photo']) - 1);
-            $photo_id = $photos['photo'][$index]['id'];
-            if (in_array($photo_id, $random_photos)) {
-              // Photo already added.
-              $i--;
-            }
-            else {
-              $random_photos[] = $photo_id;
-              $output .= theme('flickr_block_photo', array(
-                'photo' => $photos['photo'][$index],
-                'size' => $size,
-              ));
-            }
-          }
-          if ($i == 0) {
-            $output .= t('No media found !flickr.', array('!flickr' => $people['photostream']));
-            continue;
-          }
-          else {
-            // A counter if set to show.
-            $count = t('@number out of @total by !flickr', array(
-              '@number' => $i,
-              '@total' => number_format($people['count'], 0, ",", "."),
-              '!flickr' => $people['photostream'],
-            ));
-            $output .= variable_get('flickr_block_counter', 1) ? '<div class="flickr-counter">' . $count . '</div>' : '';
-          }
-        }
-    }
-    cache_set('flickr_block_' . $delta . '_' . $nsid, $output, 'cache', time() + (variable_get('flickr_block_refresh_random', 23) * 60 * 60));
-  }
-  return $output;
-}
-
-/**
- * Random from group block. Block delta: 10.
- */
-function _flickr_block_group_random($group_id, $show_n, $size, $media, $delta, $total = NULL) {
-  if ($cache = cache_get('flickr_block_' . $delta . '_' . $group_id)) {
-    $output = $cache->data;
-  }
-  else {
-    switch ($size) {
-      case "x":
-        $output = theme('flickr_flickrcomslideshow', array(
-          'id' => $group_id,
-        ));
-        drupal_set_message(t("Note that slideshows don't show in random but in reverse chronological order."), 'warning');
-        break;
-
-      case "y":
-        $output = t('Choose the Flash slideshow for group pools (size = x).');
-        drupal_set_message(t('Choose the Flash slideshow for group pools (size = x).'), 'error');
-        break;
-
-      default:
-        // Get a list of "all" the photos in the group. This is cached.
-        $response = flickr_get_group_photos($group_id, 1, array(
-            'extras' => 'media',
-        ));
-        $output = '';
-        if (!$response) {
-          return;
-        }
-        // Randomly display $show_n of them.
-        $photos = $response['photos']['photo'];
-        shuffle($photos);
-        // We shouldn't try to return more than the total number of photos.
-        $to = min($show_n, count($photos));
-        $i = 0;
-        $j = 0;
-        while ($i < $to && $j < count($photos)) {
-          if ($media == $photos[$j]['media'] . 's' || $media == 'all') {
-            $output .= theme('flickr_block_photo', array(
-              'photo' => $photos[$j],
-              'size' => $size,
-            ));
-            $i++;
-            $j++;
-          }
-          else {
-            $output .= '';
-            $j++;
-          }
-        }
-        if ($i == 0) {
-          $output .= t('No media found in the last @count posted on Flickr.', array('@count' => count($photos)));
-          continue;
-        }
-        else {
-          // A counter if set to show.
-          $flickr = l(t("group on Flickr"), 'https://www.flickr.com/groups/' . $group_id, array(
-            'attributes' => array(
-              'title' => t('View group on Flickr.'),
-              'target' => '_blank',
-            ),
-            'html' => TRUE,
-          ));
-          $count = t('@number out of @total in !flickr', array(
-            '@number' => $i,
-            '@total' => number_format($total, 0, ",", "."),
-            '!flickr' => $flickr,
-          ));
-          $output .= variable_get('flickr_block_counter', 1) ? '<div class="flickr-counter">' . $count . '</div>' : '';
-        }
-    }
-    cache_set('flickr_block_' . $delta . '_' . $group_id, $output, 'cache', time() + (variable_get('flickr_block_refresh_random', 23) * 60 * 60));
-  }
-  return $output;
-}
-
-/**
- * Random by tag block. Block delta:2 and 11.
- */
-function _flickr_block_tag_random($nsid, $show_n, $size, $media, $tags, $delta, $people = NULL) {
-  if ($cache = cache_get('flickr_block_' . $delta . '_' . $nsid . '_' . $tags)) {
-    $output = $cache->data;
-  }
-  else {
-    switch ($size) {
-      case "x":
-        $output = t('You cannot choose a slideshow for this block. Select a size.');
-        drupal_set_message(t('You cannot choose a slideshow for this block.'), 'error');
-        break;
-
-      case "y":
-        $output = t('You cannot choose a slideshow for this block. Select a size.');
-        drupal_set_message(t('You cannot choose a slideshow for this block.'), 'error');
-        break;
-
-      default:
-        $output = '';
-        if ($photos = flickr_photos_search($nsid, 1, array(
-          'per_page' => 500,
-          'extras' => 'tags',
-          'media' => $media,
-        ))) {
-          $i = 0;
-          $j = 0;
-          $response = $photos['photo'];
-          shuffle($response);
-          $terms = is_array($tags) ? $tags : explode(",", $tags);
-          if (empty($tags)) {
-            foreach ($response as $photo) {
-              if ($i < $show_n) {
-                $output .= theme('flickr_block_photo', array(
-                  'photo' => $photo,
-                  'size' => $size,
-                ));
-                $i++;
-                $j++;
-              }
-            }
-          }
-          else {
-            foreach ($terms as $term) {
-              foreach ($response as $key => $photo) {
-                if ($i >= $show_n && stripos($photo['tags'], $term) !== FALSE) {
-                  $j++;
-                }
-                elseif (stripos($photo['tags'], $term) !== FALSE) {
-                  $output .= theme('flickr_block_photo', array(
-                    'photo' => $photo,
-                    'size' => $size,
-                  ));
-                  // Avoid this image gets repeated by removing it from the
-                  // array.
-                  unset($response[$key]);
-                  $i++;
-                  $j++;
-                }
-              }
-            }
-          }
-          // A counter if set to show.
-          // The used tags with a space forced after the comma and the last
-          // one replaced by 'or'. In the link all whitespace is removed.
-          $flickr = (!empty($tags)) ? l(t("tagged <em>@tag</em>", array(
-            '@tag' => preg_replace('/(.*),/', '$1 ' . t('or'), preg_replace("/,([^\s])/", ", $1", $tags)))), $people['photosurl'] . '/tags/' . $tags, array(
-              'attributes' => array(
-                'title' => t('View tagged photos on Flickr.'),
-                'target' => '_blank',
-              ),
-              'html' => TRUE,
-            )) : '';
-          $total = (empty($tags)) ? (int) $people['count'] : $j;
-          $count = t('@number out of @total !flickr by !user', array(
-            '@number' => $i,
-            '@total' => number_format($total, 0, ",", "."),
-            '!flickr' => $flickr,
-            '!user' => $people['photostream'],
-          ));
-          $output .= variable_get('flickr_block_counter', 1) ? '<div class="flickr-counter">' . $count . '</div>' : '';
-        }
-        if ($i == 0) {
-          $output .= t('No media found in the last 500 posted on Flickr.');
-          continue;
-        }
-    }
-    cache_set('flickr_block_' . $delta . '_' . $nsid . '_' . $tags, $output, 'cache', time() + (variable_get('flickr_block_refresh_random', 23) * 60 * 60));
-  }
-  return $output;
-}
-
-/**
  * Favorites block. Block delta: 9.
  */
 function _flickr_block_favorite_public($nsid, $show_n, $size, $media, $delta) {
@@ -1262,7 +935,7 @@ function _flickr_block_favorite_public($nsid, $show_n, $size, $media, $delta) {
           $i = 0;
           foreach ($photos['photo'] as $photo) {
             if ($media == $photo['media'] . 's' || $media == 'all') {
-              $output .= theme('flickr_block_photo', array(
+              $output .= theme('flickr_photo', array(
                 'photo' => $photo,
                 'size' => $size,
               ));
@@ -1295,116 +968,3 @@ function _flickr_block_favorite_public($nsid, $show_n, $size, $media, $delta) {
   }
   return $output;
 }
-
-/**
- * This renders a block with photos from the selected groupid. Block delta: 6.
- */
-function _flickr_block_group_recent($group_id, $show_n, $size, $media, $delta, $total = NULL) {
-  if ($cache = cache_get('flickr_block_' . $delta . '_' . $group_id)) {
-    $output = $cache->data;
-  }
-  else {
-    switch ($size) {
-      case "x":
-        $output = theme('flickr_flickrcomslideshow', array(
-          'id' => $group_id,
-        ));
-        break;
-
-      case "y":
-        $output = t('Choose the Flash slideshow for group pools (size = x).');
-        drupal_set_message(t('Choose the Flash slideshow for group pools (size = x).'), 'error');
-        break;
-
-      default:
-        // Get a list of "all" the photos in the group. This is cached.
-        $response = flickr_get_group_photos($group_id, 1, array(
-            'extras' => 'media',
-        ));
-        $output = '';
-        if (!$response) {
-          return;
-        }
-        $photos = $response['photos']['photo'];
-        // We shouldn't try to return more than the total number of photos.
-        $to = min($show_n, count($photos));
-        $i = 0;
-        $j = 0;
-        while ($i < $to && $j < count($photos)) {
-          if ($media == $photos[$j]['media'] . 's' || $media == 'all') {
-            $output .= theme('flickr_block_photo', array(
-              'photo' => $photos[$j],
-              'size' => $size,
-            ));
-            $i++;
-            $j++;
-          }
-          else {
-            $output .= '';
-            $j++;
-          }
-        }
-        if ($i == 0) {
-          $output .= t('No media found in the last @count posted on Flickr.', array('@count' => count($photos)));
-          continue;
-        }
-        else {
-          // A counter if set to show.
-          $flickr = l(t("group on Flickr"), 'https://www.flickr.com/groups/' . $group_id, array(
-            'attributes' => array(
-              'title' => t('View group on Flickr.'),
-              'target' => '_blank',
-            ),
-            'html' => TRUE,
-          ));
-          $count = t('@number out of @total in !flickr', array(
-            '@number' => $i,
-            '@total' => number_format($total, 0, ",", "."),
-            '!flickr' => $flickr,
-          ));
-          $output .= variable_get('flickr_block_counter', 1) ? '<div class="flickr-counter">' . $count . '</div>' : '';
-        }
-    }
-    cache_set('flickr_block_' . $delta . '_' . $group_id, $output, 'cache', time() + (variable_get('flickr_block_refresh_others', 31) * 60 * 60));
-  }
-  return $output;
-}
-
-/**
- * Implements hook_theme().
- */
-function flickr_block_theme() {
-  return array(
-    'flickr_block_photo' => array(
-      'variables' => array('photo', 'size' => NULL),
-    ),
-    'flickr_block_photoset' => array(
-      'variables' => array('photoset', 'owner', 'size'),
-    ),
-  );
-}
-
-/**
- * Theme photo blocks.
- */
-function theme_flickr_block_photo($variables) {
-  $photo = $variables['photo'];
-  $size = $variables['size'];
-  return theme('flickr_photo', array('photo' => $photo, 'size' => $size));
-}
-
-/**
- * Theme photoset blocks. Used by photoset the blocks. Block delta: 1 and 4.
- */
-function theme_flickr_block_photoset($variables) {
-  $photoset = $variables['photoset'];
-  $owner = $variables['owner'];
-  $size = $variables['size'];
-  $media = isset($variables['media']) ? $variables['media'] : 'all';
-  return theme('flickr_photoset', array(
-    'photoset' => $photoset,
-    'owner' => $owner,
-    'size' => $size,
-    'media' => $media,
-  ));
-}
diff --git a/filter/flickr_filter.module b/filter/flickr_filter.module
index a78ef00..2b360a2 100644
--- a/filter/flickr_filter.module
+++ b/filter/flickr_filter.module
@@ -23,7 +23,7 @@ function flickr_filter_help($path, $arg) {
 function flickr_filter_info() {
   $filters['flickr_filter'] = array(
     'title' => t('Flickr linker'),
-    'description' => t('Allows you to Insert Flickr images: [flickr-photo:id=7357144724,size=m], [flickr-photoset:id=72157634563269642,size=s,num=8,media=all,random=true], [flickr-group:id=91484156@N00] or [flickr-user:id=98518260@N02, size=y].'),
+    'description' => t('Allows you to Insert Flickr images: [flickr-photo:id=7357144724,size=m], [flickr-photoset:id=72157634563269642,size=s,num=8,media=all,random=true, count=false], [flickr-group:id=91484156@N00, size=q, num=8, tags=kids/men, media=all, random=true, count=false] or [flickr-user:id=98518260@N02, size=q, num=8, tags=kids/men, media=all, random=true, count=false].'),
     'process callback' => 'flickr_filter',
     'tips callback' => 'flickr_filter_tips',
     'weight' => 9,
@@ -41,13 +41,19 @@ function flickr_filter_tips($filter, $format, $long = FALSE) {
       'target' => '_blank',
     ),
   ));
- $config = l(t('set in config'), 'admin/config/media/flickr/', array(
+  $config = l(t('set in config'), 'admin/config/media/flickr/', array(
     'attributes' => array(
       'title' => t('Go to Flickr configuration page'),
     ),
   ));
   $count = variable_get('flickr_block_counter', 1) ? 'true' : 'false';
-  $output = t("Insert Flickr images: [flickr-photo:id=7357144724,size=m], [flickr-photoset:id=72157634563269642,size=s,num=8,media=all,random=true,count=false], [flickr-group:id=91484156@N00] or [flickr-user:id=98518260@N02, size=y].<br />!find_id If you ommit parameters the following values will be used: <em>size=@default_size</em> (!config). Only for sets: <em>num=@default_number</em> (!config), <em>media=photos</em>, <em>random=false</em>, <em>count=@default_count</em> (!config).<br />Float photos:<br />Use [flickr-photo:id=9247386562, class=floatright], [flickr-photo:id=9247388074, size=m, style=float:left;] or use the <a href='https://drupal.org/project/autofloat'>AutoFloat module</a>.<br />Common sizes:<br /> s : small square 75<br /> t : thumbnail, 100 on longest side<br /> q : big square 150<br /> m : small, 240 on longest side<br /> n : small, 320 on longest side<br /> - : medium, 500 on longest side<br /> x: Flash responsive slideshow (for group, set and user IDs only)<br /> y: Basic responsive slideshow (for set and user IDs only)<br /> If the wrong size is applied, check if it exists on the Flickr photo page > Actions > View all sizes.", array('!find_id' => $idgettr, '@default_size' => variable_get('flickr_default_size', 'm'), '@default_number' => variable_get('flickr_photos_per_page', 20), '@default_count' => $count, '!config' => $config));
+  $output = t("Insert Flickr images: [<strong>flickr-photo:id</strong>=7357144724, size=m], [<strong>flickr-photoset:id</strong>=72157634563269642, size=s, num=8, media=all, random=true, count=false], [<strong>flickr-group:id</strong>=91484156@N00, size=q, num=8, tags=kids/men, media=all, random=true, count=false] or [<strong>flickr-user:id</strong>=98518260@N02, size=q, num=8, tags=kids/men, media=all, random=true, count=false].<br />!find_id Ommiting parameters the following <strong>default values</strong> will be used: <strong><em>size=@default_size</em></strong> (!config). Only for sets: <strong><em>num=@default_number</em></strong> (!config), <strong><em>media=photos</em></strong>, <strong><em>random=false</em></strong>, <strong><em>count=@default_count</em></strong> (!config).<br />Adding <strong><em>tags</em></strong> filters Flickr photos to those that are tagged as such, even partially and case insensitive (e.g. <em>'Beach'</em> matches <em>'beachtrip'</em>. Note that Flickr removes any whitespace from tags (e.g. <em>'Victoria park'</em> becomes <em>'victoriapark'</em>. Multiple tags should be seperated by a slash (/) and matches all photos that are tagged with at least one of those (OR).<br /><strong>Float single photos</strong>: Use [flickr-photo:id=9247386562, class=floatright], [flickr-photo:id=9247388074, size=m, style=float:left;] or use the <a href='https://drupal.org/project/autofloat'>AutoFloat module</a>.<br />Common sizes:<br /> s : small square 75<br /> t : thumbnail, 100 on longest side<br /> q : big square 150<br /> m : small, 240 on longest side<br /> n : small, 320 on longest side<br /> - : medium, 500 on longest side<br /> x: Flash responsive slideshow (for group, set and user IDs only)<br /> y: Basic responsive slideshow (for set and user IDs only)<br /> If the wrong size is applied, check if it exists on the Flickr photo page > Actions > View all sizes.", array(
+    '!find_id' => $idgettr,
+    '@default_size' => variable_get('flickr_default_size', 'm'),
+    '@default_number' => variable_get('flickr_photos_per_page', 20),
+    '@default_count' => $count,
+    '!config' => $config,
+  ));
   if ($long) {
     $output .= ' ' . t('The size parameter can be one of the following:');
     $items = array();
@@ -72,7 +78,7 @@ function flickr_filter($text, $filter) {
 
 /**
  * Parse parameters to the fiter from a format like:
- * id=26159919@N00, size=m,num = 9, class=something,style=float:left;border:1px
+ * id=26159919@N00, size=m,num=9,class=something,style=float:left;border:1px
  * into an associative array with two sub-arrays. The first sub-array are
  * parameters for the request, the second are HTML attributes (class and style).
  */
@@ -84,7 +90,7 @@ function flickr_filter_split_config($string) {
   // Put each setting on its own line.
   $string = str_replace(',', "\n", $string);
   // Break them up around commas.
-  preg_match_all('/([a-zA-Z]+)=([-@0-9a-zA-Z :;]+)/', $string, $parts, PREG_SET_ORDER);
+  preg_match_all('/([a-zA-Z]+)=([-@\/0-9a-zA-Z :;]+)/', $string, $parts, PREG_SET_ORDER);
   foreach ($parts as $part) {
     // Normalize to lowercase and remove extra spaces.
     $name = strtolower(trim($part[1]));
@@ -149,15 +155,16 @@ function flickr_filter_callback_photoset($matches) {
       if (!isset($config['count'])) {
         $config['count'] = variable_get('flickr_block_counter', 1) ? 'true' : 'false';
       }
+      $config['random'] = $config['random'] == 'true' ? 1 : 0;
       $output = "<div class='flickr-photoset'>\n";
       // Choose between 'recent' or 'random' based on 'random' parameter.
       // We abuse $delta parameter to override preference of counter display.
-      $output .=  ($config['random'] == 'false') ? _flickr_photoset_recent($photoset['owner'], $config['num'], $config['size'], $config['media'], $photoset['id'], $config['count']) : _flickr_photoset_random($photoset['owner'], $config['num'], $config['size'], $config['media'], $photoset['id'], $config['count']);
+      $output .= _flickr_photoset($photoset['owner'], $config['num'], $config['size'], $config['media'], $photoset['id'], $config['count'], $config['random']);
       $output .= '</div>';
       return $output;
     }
   }
-    return '';
+  return '';
 }
 
 /**
@@ -167,13 +174,35 @@ function flickr_filter_callback_group($matches) {
   list($config, $attribs) = flickr_filter_split_config($matches[1]);
 
   if (isset($config['id'])) {
-    if ($photoset = flickr_get_group_photos($config['id'])) {
+    if ($info = flickr_groups_getinfo($config['id'])) {
       if (!isset($config['size'])) {
-        $config['size'] = 'x';
+        $config['size'] = variable_get('flickr_default_size', 'm');
       }
-      return theme('flickr_flickrcomslideshow', array(
-        'id' => $config['id'],
-      ));
+      if (!isset($config['num'])) {
+        $config['num'] = variable_get('flickr_photos_per_page', 20);
+      }
+      if (!isset($config['media'])) {
+        $config['media'] = 'photos';
+      }
+      if (!isset($config['random'])) {
+        $config['random'] = 'false';
+      }
+      if (!isset($config['tags'])) {
+        $config['tags'] = '';
+      }
+      else {
+        $config['tags'] = str_replace("/", ",", $config['tags']);
+      }
+      if (!isset($config['count'])) {
+        $config['count'] = variable_get('flickr_block_counter', 1) ? 'true' : 'false';
+      }
+      $config['random'] = $config['random'] == 'true' ? 1 : 0;
+      $output = "<div class='flickr-photoset'>\n";
+      // Choose between 'recent' or 'random' based on 'random' parameter.
+      // We abuse $delta parameter to override preference of counter display.
+      $output .= _flickr_group($config['id'], $config['num'], $config['size'], $config['media'], $config['tags'], $config['count'], $info['group']['pool_count']['_content'], $config['random']);
+      $output .= '</div>';
+      return $output;
     }
   }
   return '';
@@ -186,21 +215,35 @@ function flickr_filter_callback_user($matches) {
   list($config, $attribs) = flickr_filter_split_config($matches[1]);
 
   if (isset($config['id'])) {
-    if ($photoset = flickr_people_getpublicphotos($config['id'])) {
+    if ($people = flickr_get_user_info($config['id'])) {
       if (!isset($config['size'])) {
-        $config['size'] = 'x';
+        $config['size'] = variable_get('flickr_default_size', 'm');
       }
-      switch ($config['size']) {
-        case "x":
-          return theme('flickr_flickrcomslideshow', array('id' => $config['id']));
-
-        case "y":
-          return theme('flickr_flickrcomslideshow_simple', array('id' => $config['id']));
-
-        default:
-          drupal_set_message(t("You can only use a slideshow for a user's photostream (size = x or y)."), 'error');
-          return theme('flickr_flickrcomslideshow', array('id' => $config['id']));
+      if (!isset($config['num'])) {
+        $config['num'] = variable_get('flickr_photos_per_page', 20);
+      }
+      if (!isset($config['media'])) {
+        $config['media'] = 'photos';
       }
+      if (!isset($config['random'])) {
+        $config['random'] = 'false';
+      }
+      if (!isset($config['tags'])) {
+        $config['tags'] = '';
+      }
+      else {
+        $config['tags'] = str_replace("/", ",", $config['tags']);
+      }
+      if (!isset($config['count'])) {
+        $config['count'] = variable_get('flickr_block_counter', 1) ? 'true' : 'false';
+      }
+      $config['random'] = $config['random'] == 'true' ? 1 : 0;
+      $output = "<div class='flickr-photoset'>\n";
+      // Choose between 'recent' or 'random' based on 'random' parameter.
+      // We abuse $delta parameter to override preference of counter display.
+      $output .= _flickr_user($config['id'], $config['num'], $config['size'], $config['media'], $config['tags'], $config['count'], $people, $config['random']);
+      $output .= '</div>';
+      return $output;
     }
   }
   return '';
diff --git a/flickr.api.inc b/flickr.api.inc
index d8af7e3..b635cb7 100644
--- a/flickr.api.inc
+++ b/flickr.api.inc
@@ -313,7 +313,7 @@ function flickr_get_group_photos($nsid, $page = 1, $other_args = array()) {
 
   // Set per_page to flickr module default if not specified in $other_args.
   if (!isset($other_args['per_page'])) {
-//    $args['per_page'] = variable_get('flickr_photos_per_page', 20);
+    $args['per_page'] = variable_get('flickr_photos_per_page', 20);
   }
 
   $response = flickr_request('flickr.groups.pools.getPhotos', array_merge($args, $other_args));
diff --git a/flickr.inc b/flickr.inc
index 6ac032c..5ba8a06 100644
--- a/flickr.inc
+++ b/flickr.inc
@@ -451,10 +451,10 @@ function flickr_get_user_info($nsid) {
 }
 
 /**
- * Random from photoset. Used by block 7 and random Filter photoset-id.
+ * Media from photoset. Used by blocks 7, 8 and text filter photoset-id.
  */
-function _flickr_photoset_random($nsid, $show_n, $size, $media, $photoset_id, $delta = NULL) {
-  $cache = cache_get('flickr_block_' . $delta . '_' . $photoset_id);
+function _flickr_photoset($nsid, $show_n, $size, $media, $photoset_id, $delta = NULL, $random = 0) {
+  $cache = cache_get('flickr_block_' . $delta . '_' . $photoset_id . '_' . $random);
   // If $delta is a number it is a block that could be cached.
   if ($cache && is_numeric($delta)) {
     $output = $cache->data;
@@ -465,14 +465,14 @@ function _flickr_photoset_random($nsid, $show_n, $size, $media, $photoset_id, $d
         $output = theme('flickr_flickrcomslideshow', array(
           'id' => $photoset_id,
         ));
-        drupal_set_message(t("Note that slideshows don't show in random but in reverse chronological order and ignore number and media settings."), 'warning');
+        drupal_set_message(t("Note that slideshows show in reverse chronological order (newest first) and ignore number and media settings."), 'warning');
         break;
 
       case "y";
         $output = theme('flickr_flickrcomslideshow_simple', array(
           'id' => $photoset_id,
         ));
-        drupal_set_message(t("Note that slideshows don't show in random but in reverse chronological order and ignore number and media settings."), 'warning');
+        drupal_set_message(t("Note that slideshows reverse chronological order (newest first) and ignore number and media settings."), 'warning');
         break;
 
       default:
@@ -493,15 +493,16 @@ function _flickr_photoset_random($nsid, $show_n, $size, $media, $photoset_id, $d
           return;
         }
 
-        // Randomly display $show_n of them.
         $photos = $response['photoset']['photo'];
-        shuffle($photos);
+        if ($random == 1) {
+          shuffle($photos);
+        }
         // We shouldn't try to return more than the total number of photos.
         $to = min($show_n, count($photos));
         for ($i = 0; $i < $to; $i++) {
           // Insert owner into $photo because theme_flickr_photo needs it.
           $photos[$i]['owner'] = $info['owner'];
-          $output .= theme('flickr_block_photo', array(
+          $output .= theme('flickr_photo', array(
             'photo' => $photos[$i],
             'size' => $size,
           ));
@@ -528,18 +529,18 @@ function _flickr_photoset_random($nsid, $show_n, $size, $media, $photoset_id, $d
           $output .= ((variable_get('flickr_block_counter', 1) && $delta != 'false') || $delta == 'true') ? '<div class="flickr-counter">' . $count . '</div>' : '';
         }
     }
-    if (!is_null($delta)) {
-      cache_set('flickr_block_' . $delta . '_' . $photoset_id, $output, 'cache', time() + (variable_get('flickr_block_refresh_random', 23) * 60 * 60));
+    if (is_numeric($delta)) {
+      cache_set('flickr_block_' . $delta . '_' . $photoset_id . '_' . $random, $output, 'cache', time() + (variable_get('flickr_block_refresh_random', 23) * 60 * 60));
     }
   }
   return $output;
 }
 
 /**
- * Recent from photoset. Used by block 8 and not random Filter photoset-id.
+ * User media by tags. Used by blocks 2, 5, 11 and text filter user-id.
  */
-function _flickr_photoset_recent($nsid, $show_n, $size, $media, $photoset_id, $delta = NULL) {
-  $cache = cache_get('flickr_block_' . $delta . '_' . $photoset_id);
+function _flickr_user($nsid, $show_n, $size, $media, $tags, $delta, $people = NULL, $random = 0) {
+  $cache = cache_get('flickr_block_' . $delta . '_' . $nsid . '_' . $tags . '_' . $random);
   // If $delta is a number it is a block that could be cached.
   if ($cache && is_numeric($delta)) {
     $output = $cache->data;
@@ -548,64 +549,198 @@ function _flickr_photoset_recent($nsid, $show_n, $size, $media, $photoset_id, $d
     switch ($size) {
       case "x";
         $output = theme('flickr_flickrcomslideshow', array(
-          'id' => $photoset_id,
+          'id' => $nsid,
         ));
-        drupal_set_message(t("Note that slideshows ignore number and media settings."), 'warning');
+        drupal_set_message(t("Note that slideshows show in reverse chronological order and ignore number, tags and media settings."), 'warning');
         break;
 
       case "y";
         $output = theme('flickr_flickrcomslideshow_simple', array(
-          'id' => $photoset_id,
+          'id' => $nsid,
         ));
-        drupal_set_message(t("Note that slideshows ignore number and media settings."), 'warning');
+        drupal_set_message(t("Note that slideshows show in reverse chronological order (newest first) and ignore number, tags and media settings."), 'warning');
         break;
 
       default:
         $output = '';
-        $response = flickr_photosets_getphotos($photoset_id, array(
-            'per_page' => $show_n,
-            'media' => $media,
+        if ($photos = flickr_photos_search($nsid, 1, array(
+          'per_page' => 500,
+          'extras' => 'tags',
+          'media' => $media,
+        ))) {
+          $i = 0;
+          $j = 0;
+          $response = $photos['photo'];
+          if ($random == 1) {
+            shuffle($response);
+          }
+          $terms = is_array($tags) ? $tags : explode(",", $tags);
+          if (empty($tags)) {
+            foreach ($response as $photo) {
+              if ($i < $show_n) {
+                $output .= theme('flickr_photo', array(
+                  'photo' => $photo,
+                  'size' => $size,
+                ));
+                $i++;
+                $j++;
+              }
+            }
+          }
+          else {
+            foreach ($terms as $term) {
+              foreach ($response as $key => $photo) {
+                if ($i >= $show_n && stripos($photo['tags'], $term) !== FALSE) {
+                  $j++;
+                }
+                elseif (stripos($photo['tags'], $term) !== FALSE) {
+                  $output .= theme('flickr_photo', array(
+                    'photo' => $photo,
+                    'size' => $size,
+                  ));
+                  // Avoid this image gets repeated by removing it from the
+                  // array.
+                  unset($response[$key]);
+                  $i++;
+                  $j++;
+                }
+              }
+            }
+          }
+          // A counter if set to show.
+          // The used tags with a space forced after the comma and the last
+          // one replaced by 'or'. In the link all whitespace is removed.
+          $flickr = (!empty($tags)) ? l(t("tagged <em>@tag</em>", array(
+            '@tag' => preg_replace('/(.*),/', '$1 ' . t('or'), preg_replace("/,([^\s])/", ", $1", $tags)))), $people['photosurl'] . 'tags/' . $tags, array(
+              'attributes' => array(
+                'title' => t('View tagged photos on Flickr.'),
+                'target' => '_blank',
+              ),
+              'html' => TRUE,
+            )) : '';
+          $total = (empty($tags)) ? (int) $people['count'] : $j;
+          $count = t('@number out of @total !flickr by !user', array(
+            '@number' => $i,
+            '@total' => number_format($total, 0, ",", "."),
+            '!flickr' => $flickr,
+            '!user' => $people['photostream'],
           ));
+          $output .= ((variable_get('flickr_block_counter', 1) && $delta != 'false') || $delta == 'true') ? '<div class="flickr-counter">' . $count . '</div>' : '';
+        }
+        if ($i == 0) {
+          $output .= t('No media found in the last 500 posted on Flickr.');
+          continue;
+        }
+    }
+    if (is_numeric($delta)) {
+      cache_set('flickr_block_' . $delta . '_' . $nsid . '_' . $tags . '_' . $random, $output, 'cache', time() + (variable_get('flickr_block_refresh_random', 23) * 60 * 60));
+    }
+  }
+  return $output;
+}
+
+/**
+ * Media from group. Used by locks 6, 10 and text filter group-id.
+ */
+function _flickr_group($group_id, $show_n, $size, $media, $tags, $delta, $total = NULL, $random = 0) {
+  $cache = cache_get('flickr_block_' . $delta . '_' . $group_id . '_' . $tags . '_' . $random);
+  // If $delta is a number it is a block that could be cached.
+  if ($cache && is_numeric($delta)) {
+    $output = $cache->data;
+  }
+  else {
+    switch ($size) {
+      case "x":
+        $output = theme('flickr_flickrcomslideshow', array(
+          'id' => $group_id,
+        ));
+        drupal_set_message(t("Note that slideshows show in reverse chronological order (newest first) and ignore number, tags and media settings."), 'warning');
+        break;
+
+      case "y":
+        $output = t('Choose the Flash slideshow for group pools (size = x).');
+        drupal_set_message(t('Choose the Flash slideshow for group pools (size = x).'), 'error');
+        break;
 
+      default:
+        // Get a list of "all" the photos in the group. This is cached.
+        $response = flickr_get_group_photos($group_id, 1, array(
+            'per_page' => 500,
+            'extras' => 'tags,media',
+        ));
+        $output = '';
         if (!$response) {
           return;
         }
-        // Only show the counter if the number of items is inferior to the total
-        // available on Flickr.
+        $photos = $response['photos']['photo'];
+        if ($random == 1) {
+          shuffle($photos);
+        }
+        // We shouldn't try to return more than the total number of photos.
+        $to = min($show_n, count($photos));
         $i = 0;
-        foreach ($response['photoset']['photo'] as $photo) {
-          // Insert owner into $photo because theme_flickr_photo needs it.
-          $photo['owner'] = $response['photoset']['owner'];
-          $output .= theme('flickr_block_photo', array(
-            'photo' => $photo,
-            'size' => $size,
-          ));
-          $i++;
+        $j = 0;
+        $terms = is_array($tags) ? $tags : explode(",", $tags);
+        if (empty($tags)) {
+          while ($i < $to && $j < count($photos)) {
+            if ($media == $photos[$j]['media'] . 's' || $media == 'all') {
+              $output .= theme('flickr_photo', array(
+                'photo' => $photos[$j],
+                'size' => $size,
+              ));
+              $i++;
+              $j++;
+            }
+            else {
+              $output .= '';
+              $j++;
+            }
+          }
+        }
+        else {
+          foreach ($terms as $term) {
+            while ($i < $to && $j < count($photos)) {
+              if (($media == $photos[$j]['media'] . 's' || $media == 'all') && stripos($photos[$j]['tags'], $term) !== FALSE) {
+                $output .= theme('flickr_photo', array(
+                  'photo' => $photos[$j],
+                  'size' => $size,
+                ));
+                // Avoid this image gets repeated by removing it from the
+                // array.
+                unset($photos[$j]);
+                $i++;
+                $j++;
+              }
+              else {
+                $output .= '';
+                $j++;
+              }
+            }
+          }
         }
         if ($i == 0) {
-          $output .= t('No media found in the set posted on Flickr.');
+          $output .= t('No media found in the last @count posted on Flickr.', array('@count' => count($photos)));
           continue;
         }
         else {
           // A counter if set to show.
-          $flickr = l(t("set on Flickr"), 'https://www.flickr.com/photos/' . $nsid . '/sets/' . $photoset_id, array(
+          $flickr = l(t("group on Flickr"), 'https://www.flickr.com/groups/' . $group_id, array(
             'attributes' => array(
-              'title' => t('View set on Flickr.'),
+              'title' => t('View group on Flickr.'),
               'target' => '_blank',
             ),
             'html' => TRUE,
           ));
           $count = t('@number out of @total in !flickr', array(
             '@number' => $i,
-            '@total' => number_format($response['photoset']['total'], 0, ",", "."),
+            '@total' => number_format($total, 0, ",", "."),
             '!flickr' => $flickr,
           ));
-          // If $delta is non numeric allow counter override from filter module.
-          $output .= ((variable_get('flickr_block_counter', 1) && $delta != 'false') || $delta == 'true') ? '<div class="flickr-counter">' . $count . '</div>' : '';
+          $output .= variable_get('flickr_block_counter', 1) ? '<div class="flickr-counter">' . $count . '</div>' : '';
         }
     }
-    if (!is_null($delta)) {
-      cache_set('flickr_block_' . $delta . '_' . $photoset_id, $output, 'cache', time() + (variable_get('flickr_block_refresh_others', 31) * 60 * 60));
+    if (is_numeric($delta)) {
+      cache_set('flickr_block_' . $delta . '_' . $group_id . '_' . $tags . '_' . $random, $output, 'cache', time() + (variable_get('flickr_block_refresh_random', 23) * 60 * 60));
     }
   }
   return $output;
