You are here

function FileStyles::thumbnail in Styles 7.2

File

contrib/file_styles/includes/styles/FileStyles.inc, line 135
styles/contrib/file_styles/includes/styles/FileStyles.inc Styles definitions for file styles.

Class

FileStyles
@file styles/contrib/file_styles/includes/styles/FileStyles.inc Styles definitions for file styles.

Code

function thumbnail($effect) {
  $attributes = array();
  $width = $this
    ->getWidth();
  $height = $this
    ->getHeight();
  if (isset($width)) {
    $attributes['width'] = $width;
  }
  if (isset($height)) {
    $attributes['height'] = $height;
  }

  // We have a .media-image class for WYSIWYG.
  // We can't used ->getClass, because that's restricted.
  $class = $this
    ->override('class');
  if (isset($class)) {
    $attributes['class'] = $class;
  }

  // Set any WYSIWYG prescribed styles.
  $style = $this
    ->override('style');
  $attributes['style'] = isset($style) ? $style . ';' : '';
  foreach (array(
    'border-width',
    'border-style',
    'display',
    'float',
    'margin',
    'margin-top',
    'margin-right',
    'margin-bottom',
    'margin-left',
  ) as $property) {
    $value = $this
      ->override($property);
    if (isset($value)) {
      $attributes['style'] .= $property . ':' . $value . ';';
    }
  }
  if ($attributes['style'] == '') {
    unset($attributes['style']);
  }

  // Set any additional prescribed attributes.
  // @todo Remove this as a hard-coded list. Note that not everything in
  //   $this->getObject()->override is an HTML attribute.
  foreach (array(
    'id',
    'class',
    'dir',
    'lang',
  ) as $attribute) {
    $value = $this
      ->override($attribute);
    if (!empty($value)) {
      $attributes[$attribute] = $value;
    }
  }
  if ($imageUri = $this
    ->getImageUri()) {
    $this
      ->setOutput(theme('file_styles_image', array(
      'image_uri' => $imageUri,
      'attributes' => $attributes,
      'alt' => $this
        ->getAlt(),
      'title' => $this
        ->getTitle(),
      'image_style' => $this
        ->getImageStyle(),
      'instance' => $this,
    )));

    // Honor any applied links.
    if ($link = $this
      ->getLink()) {
      $this
        ->setOutput(l($this
        ->getOutput(), $link, array(
        'html' => TRUE,
      )));
    }
  }
}