You are here

class image_gallery_handler_field_gallery_cover_thumbnail in Image 6

Same name and namespace in other branches
  1. 7 contrib/image_gallery/views/image_gallery_handler_field_gallery_cover_thumbnail.inc \image_gallery_handler_field_gallery_cover_thumbnail

Field handler for gallery cover node image.

Displays a thumbnail of the cover image node, at the chosen derivative size. This covers basic cases where the handler definition can specify the query and the order to get the cover node.

Hierarchy

Expanded class hierarchy of image_gallery_handler_field_gallery_cover_thumbnail

1 string reference to 'image_gallery_handler_field_gallery_cover_thumbnail'
image_gallery_views_data_alter in contrib/image_gallery/views/image_gallery.views.inc
Implementation of hook_views_data_alter(). Add fields for image gallery (ie vocabulary terms) to the term_data table.

File

contrib/image_gallery/views/image_gallery_handler_field_gallery_cover_thumbnail.inc, line 10

View source
class image_gallery_handler_field_gallery_cover_thumbnail extends image_gallery_handler_field_gallery_cover {

  /**
   * Defines default values for options.
   */
  function option_definition() {
    $options = parent::option_definition();
    $options['image_derivative'] = array(
      'default' => array(
        IMAGE_THUMBNAIL,
      ),
    );
    return $options;
  }

  /**
   * Extends the field's basic options with more image specific options.
   */
  function options_form(&$form, &$form_state) {
    parent::options_form($form, $form_state);

    // Overwrite the descendants option so the text is relevant.
    $form['descendants']['#description'] = theme('advanced_help_topic', 'image_gallery', 'descendants') . t('Whether to go into subgalleries when getting a cover image. Either: consider only this gallery itself, consider subgalleries all together, or recurse into subgalleries one by one if the gallery itself is empty.');
    $form['descendants']['#options'] = array(
      'single' => t('Only get cover image from this gallery'),
      'flat' => t('Consider subgalleries, flattened.'),
      'recurse' => t('Consider subgalleries, recursively. (Warning: this can produce many queries per row if your parent galleries are empty!).'),
    );
    foreach (image_get_sizes() as $key => $size) {
      $sizes[$key] = $size['label'];
    }
    $form['image_derivative'] = array(
      '#type' => 'select',
      '#title' => t('Image size to show'),
      '#options' => $sizes,
      '#default_value' => $this->options['image_derivative'],
      '#description' => t('Pick an image derivative to display.'),
    );
  }

  /**
   * Returns field html.
   */
  function render($values) {
    $nid = $this
      ->get_cover_node_nid($values);
    $latest_node = node_load($nid);
    $output = image_display($latest_node, $this->options['image_derivative']);
    $output = $this
      ->render_link($output, $values);

    // Wrap a common class so the thumbnail can be style no matter what field.
    // TODO: theme function?
    return '<span class="image-gallery-view-cover-thumbnail">' . $output . '</span>';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
image_gallery_handler_field_gallery_cover::construct function Constructor to provide additional fields to add.
image_gallery_handler_field_gallery_cover::get_cover_node_nid function Get the cover nid for the current tid.
image_gallery_handler_field_gallery_cover::get_cover_node_nid_query function The query this handler should use to gets its cover node id, unless the field definition specifies one.
image_gallery_handler_field_gallery_cover::get_cover_node_nid_recurse function Recursively query descendant tids until we get a cover nid.
image_gallery_handler_field_gallery_cover::init function
image_gallery_handler_field_gallery_cover::query function Override query() so we don't query: fake field.
image_gallery_handler_field_gallery_cover_thumbnail::options_form function Extends the field's basic options with more image specific options. Overrides image_gallery_handler_field_gallery_cover::options_form
image_gallery_handler_field_gallery_cover_thumbnail::option_definition function Defines default values for options. Overrides image_gallery_handler_field_gallery_cover::option_definition
image_gallery_handler_field_gallery_cover_thumbnail::render function Returns field html. Overrides image_gallery_handler_field_gallery_cover::render