You are here

function visual_select_file_views_handler_field_image::render in Visual select file 7

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

./visual_select_file_views_handler_field_image.inc, line 47

Class

visual_select_file_views_handler_field_image

Code

function render($values) {
  $path = $this
    ->get_value($values);
  $style_name = $this->options['image_style'];
  $vars = compact('path', 'style_name');
  $image = '';

  // With image style.
  if (strpos($values->{$this->filemime}, 'image/') === 0) {
    if ($style_name) {
      $image = theme('image_style', $vars);
    }
    else {
      $image = theme('image', $vars);
    }
  }
  elseif ($file = file_load($values->{$this->fid})) {
    $image = theme('file_icon', array(
      'file' => $file,
    ));
  }

  // Link image somewhere.
  $link_to = $this->options['link_to'];
  if ($link_to) {
    $uri = $path;

    // With image style.
    if ($link_to != '_original') {
      $uri = image_style_path($link_to, $path);
    }
    $uri = file_create_url($uri);
    $image = l($image, $uri, array(
      'html' => TRUE,
    ));
  }
  return $image;
}