You are here

function template_preprocess_imageblock_block in Image Block 6

Process variables for imageblock-block.tpl.php.

The $variables array contains the following arguments:

  • $block

See also

imageblock-block.tpl.php

File

./imageblock.module, line 321
imageblock.module Primarily Drupal hooks.

Code

function template_preprocess_imageblock_block(&$variables) {
  $block = $variables['block'];
  $data = !empty($block->data) ? unserialize($block->data) : array();
  if (!empty($block->fid)) {
    $file = db_fetch_object(db_query('SELECT * FROM {files} WHERE fid = %d', $block->fid));
    if (!empty($file->fid)) {
      $attributes = array(
        'class' => 'imageblock-image',
      );
      if (module_exists('imagecache') && !empty($data['imageblock_imagecache']) && ($preset = imagecache_preset_by_name($data['imageblock_imagecache']))) {
        $variables['image'] = theme('imagecache', $preset['presetname'], $file->filepath, NULL, NULL, $attributes);
      }
      else {
        $variables['image'] = theme('image', $file->filepath, NULL, NULL, $attributes);
      }
      if (!empty($data['imageblock_link'])) {
        $attributes = array(
          'class' => 'imageblock-link',
        );
        if (!empty($data['imageblock_link_target'])) {
          $attributes['target'] = $data['imageblock_link_target'];
        }
        $variables['image'] = l($variables['image'], $data['imageblock_link'], array(
          'html' => TRUE,
          'attributes' => $attributes,
        ));
      }
    }
  }
  $variables['content'] = check_markup($block->body, $block->format, FALSE);
}