You are here

function template_preprocess_imageblock_content in Image Block 7

Process variables for imageblock-content.tpl.php.

The $variables array contains the following arguments:

  • $block

See also

imageblock-content.tpl.php

File

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

Code

function template_preprocess_imageblock_content(&$variables) {
  $variables['image'] = '';
  $block = $variables['block'];
  $data = !empty($block->data) ? unserialize($block->data) : array();
  if (!empty($block->fid)) {
    $file = file_load($block->fid);
    if (!empty($file->fid)) {
      $attributes = array(
        'class' => array(
          'imageblock-image',
        ),
      );
      $variables['path'] = $file->uri;
      $variables['attributes'] = $attributes;
      if (!empty($data['imageblock_alt'])) {
        $variables['alt'] = $data['imageblock_alt'];
      }
      if (!empty($data['imageblock_title'])) {
        $variables['title'] = $data['imageblock_title'];
      }
      if (module_exists('image') && !empty($data['imageblock_imagecache']) && ($preset = image_style_load($data['imageblock_imagecache']))) {
        $variables['image'] = theme('image_style', $variables + array(
          'style_name' => $preset['name'],
        ));
      }
      else {
        $variables['image'] = theme('image', $variables);
      }
      if (!empty($data['imageblock_link'])) {
        $attributes = array(
          'class' => array(
            'imageblock-link',
          ),
        );
        if (!empty($data['imageblock_link_target'])) {
          $attributes['target'] = $data['imageblock_link_target'];
        }
        if (!empty($data['imageblock_nofollow']) && $data['imageblock_nofollow']) {
          $attributes['rel'] = 'nofollow';
        }
        $variables['image'] = l($variables['image'], $data['imageblock_link'], array(
          'html' => TRUE,
          'attributes' => $attributes,
        ));
      }
    }
  }
  if (isset($block) && is_object($block)) {
    $variables['content'] = check_markup($block->body, $block->format, '', TRUE);
  }
  else {
    $variables['content'] = '';
  }
}