Skip to content

Commit

Permalink
Added 'thumb' and 'link' options
Browse files Browse the repository at this point in the history
  • Loading branch information
Jap authored Oct 27, 2016
1 parent b69f715 commit 6cfe1a4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Lightbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
namespace branchonline\lightbox;

use yii\base\Widget;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;

class Lightbox extends Widget {

/**
* @var array containing the attributes for the images
*/
/** @var array Contains the attributes for the images. */
public $files = [];

/** @inheritdoc */
public function init() {
LightboxAsset::register($this->getView());
}

/** @inheritdoc */
public function run() {
$html = '';
foreach ($this->files as $file) {
Expand All @@ -33,11 +34,15 @@ public function run() {
$attributes['data-lightbox'] = 'image-' . uniqid();
}

$img = Html::img($file['thumb']);
$a = Html::a($img, $file['original'], $attributes);
$thumbOptions = isset($file['thumbOptions']) ? $file['thumbOptions'] : [];
$linkOptions = isset($file['linkOptions']) ? $file['linkOptions'] : [];

$img = Html::img($file['thumb'], $thumbOptions);
$a = Html::a($img, $file['original'], ArrayHelper::merge($attributes, $linkOptions));

$html .= $a;
}
return $html;
}

}
}

0 comments on commit 6cfe1a4

Please sign in to comment.