You are here

function andromeda_slideshow_block_view in Andromeda Slideshow 7.2

Same name and namespace in other branches
  1. 7 andromeda_slideshow.module \andromeda_slideshow_block_view()

Implements hook_block_view().

File

./andromeda_slideshow.module, line 196
Slideshow for the Andromeda (http://drupal.org/project/andromeda) Theme

Code

function andromeda_slideshow_block_view($delta = '') {
  $block = array();
  $name = $delta;
  $slideshow = andromeda_slideshow_load_by_name($name);
  if ($slideshow) {
    $images = andromeda_slideshow_load_slideshow_images($slideshow->sid);
    $type_name = isset($slideshow->settings['type']) ? $slideshow->settings['type'] : 'andromeda_slideshow';
    $theme = 'andromeda_slideshow_' . $type_name;
    $type = andromeda_slideshow_build_type($type_name);

    //build image style, tag and links
    $style_name = $slideshow->settings['image_style'];
    foreach ($images as $key => $image) {
      $tag = theme('image_style', array(
        'style_name' => $style_name,
        'path' => $image->uri,
        'title' => $image->caption,
      ));
      $images[$key]->image_tag = $image->settings['link'] ? l($tag, $image->settings['link'], array(
        'html' => true,
      )) : $tag;
      $images[$key]->image = image_style_url($style_name, $image->uri);
      if ($image->settings['link']) {
        $images[$key]->settings['link'] = url($image->settings['link']);
      }
    }
    if (sizeof($images)) {
      $block['subject'] = $slideshow->title;
      $block['content']['#attached']['css'] = $type['styles'];
      $block['content']['#attached']['js'] = $type['scripts'];
      $block['content']['#markup'] = theme($theme, array(
        'slideshow' => $slideshow,
        'images' => $images,
      ));
    }
  }
  return $block;
}