Skip to content

Commit

Permalink
Added grouping functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Jap Mul Eindbaas committed Jun 29, 2015
1 parent e2718f5 commit 478237e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/Lightbox.php
Expand Up @@ -7,6 +7,9 @@

class Lightbox extends Widget {

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

public function init() {
Expand All @@ -15,19 +18,26 @@ public function init() {

public function run() {
$html = '';
foreach($this->files as $file) {
if(!isset($file['thumb']) || !isset($file['original'])) {
foreach ($this->files as $file) {
if (!isset($file['thumb']) || !isset($file['original'])) {
continue;
}

$img = Html::img($file['thumb']);
$a = Html::a($img, $file['original'], [
'data-lightbox' => 'image-' . uniqid(),
$attributes = [
'data-title' => isset($file['title']) ? $file['title'] : '',
]);
];

if (isset($file['group'])) {
$attributes['data-lightbox'] = $file['group'];
} else {
$attributes['data-lightbox'] = 'image-' . uniqid();
}

$img = Html::img($file['thumb']);
$a = Html::a($img, $file['original'], $attributes);
$html .= $a;
}
return $html;
}

}
}

0 comments on commit 478237e

Please sign in to comment.