You are here

function template_preprocess_lightbox2_insert_image in Lightbox2 8

Same name and namespace in other branches
  1. 6 lightbox2.insert.inc \template_preprocess_lightbox2_insert_image()
  2. 7.2 lightbox2.insert.inc \template_preprocess_lightbox2_insert_image()
  3. 7 lightbox2.insert.inc \template_preprocess_lightbox2_insert_image()

Theme the content that will be inserted for Lightbox2 presets.

File

./lightbox2.insert.inc, line 52
Lightbox2 support for Insert module.

Code

function template_preprocess_lightbox2_insert_image(&$vars) {
  if ($vars['image_preset_name'] != 'original') {
    $filepath = imagecache_create_path($vars['image_preset_name'], $vars['item']['filepath']);
  }
  else {
    $filepath = $vars['item']['filepath'];
  }
  $vars['url'] = insert_create_url($filepath);
  if ($vars['link_preset_name'] != 'original') {
    $linkpath = imagecache_create_path($vars['link_preset_name'], $vars['item']['filepath']);
  }
  else {
    $linkpath = $vars['item']['filepath'];
  }
  $vars['linkurl'] = insert_create_url($linkpath);
  $vars['download_link'] = '';
  $download_link_text = \Drupal\Component\Utility\Html::escape(\Drupal::config('lightbox2.settings')
    ->get('lightbox2_download_link_text'));
  if (!empty($download_link_text) && \Drupal::currentUser()
    ->hasPermission('download original image')) {

    // @FIXME
    // l() expects a Url object, created from a route name or external URI.
    // $vars['download_link'] = '<br /><br />' . l($download_link_text, $vars['linkurl'], array('attributes' => array('target' => '_blank', 'id' => 'lightbox2-download-link-text')));
  }
  $vars['class'] = !empty($vars['widget']['insert_class']) ? $vars['widget']['insert_class'] : '';
}