You are here

function lightgallery_style_plugin::render_fields in Lightgallery 7

Renders the view fields.

Parameters

type $result:

Return value

type

Overrides views_plugin_style::render_fields

File

views/lightgallery_style_plugin.inc, line 352
Contains the lightgallery style plugin.

Class

lightgallery_style_plugin
Style plugin to render views as lightgallery instance.

Code

function render_fields($result) {
  $this->rendered_fields = array();
  $this->view->row_index = 0;
  $keys = array_keys($this->view->field);

  // If all fields have a field::access FALSE there might be no fields, so
  // there is no reason to execute this code.
  if (!empty($keys)) {
    $fields = $this
      ->conf_get_field_sources();
    $image_fields = array_keys($fields['field_options_images']);
    foreach ($result as $count => $row) {
      $this->view->row_index = $count;
      foreach ($keys as $id) {
        if (in_array($id, $image_fields)) {

          // This is an image/thumb field.
          // Create URI for selected image style.
          $image_style = $this->view->field[$id]->options['settings']['image_style'];
          $uri = !empty($result[$count]->{'field_' . $id}[0]['raw']['uri']) ? $result[$count]->{'field_' . $id}[0]['raw']['uri'] : FALSE;
          if ($uri) {
            if (!empty($image_style)) {
              $this->rendered_fields[$count][$id] = file_create_url(image_style_url($image_style, $uri));
            }
            else {
              $this->rendered_fields[$count][$id] = file_create_url($uri);
            }
          }
        }
        else {

          // Just render the field as views would do.
          $this->rendered_fields[$count][$id] = $this->view->field[$id]
            ->theme($row);
        }
      }
      $this->row_tokens[$count] = $this->view->field[$id]
        ->get_render_tokens(array());
    }
  }
  unset($this->view->row_index);
  return $this->rendered_fields;
}