public function thumbnails()
{
// $img = module('dynamic')->placeholder_img(array('width' => 300, 'height' => 200));
$img = url('/dynamic/placeholder/300x200');
return _class('html')->thumbnails([
[
'img' => $img,
],
[
'img' => $img,
'head' => 'Thumbnail label 4',
],
[
'img' => $img,
'alt' => '300x200',
'head' => 'Thumbnail label 1',
'body' => '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<p><a href="#" class="btn btn-primary">Action</a> <a href="#" class="btn">Action</a></p>',
],
$img,
[
'img' => $img,
'alt' => '300x200',
'head' => 'Thumbnail label 2',
'body' => '<p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>',
],
$img,
], ['columns' => 3]);
}
public function thumbnails($data = [], $extra = [])
{
$items = [];
$columns = (int) $extra['columns'] ?: 3;
$row_class = 'span' . round(12 / $columns) . ' col-md-' . round(12 / $columns);
foreach ((array) $data as $k => $v) {
if ( ! is_array($v)) {
$img_src = $v;
$v = [];
} else {
$img_src = $v['img'];
}
$class_item = $v['class_item'] ?: $extra['class_item'];
$tag = $this->_is_bs3 ? 'div' : 'li';
$items[] =
'<' . $tag . ' class="' . $row_class . ($class_item ? ' ' . $class_item : '') . ($v['style'] ? ' style="' . $v['style'] . '"' : '') . '">
<div class="thumbnail">
<img alt="' . _prepare_html($v['alt'] ?: $v['head']) . '" src="' . _prepare_html($img_src) . '" />
' . (($v['head'] || $v['body']) ? '<div class="caption">' . ($v['head'] ? '<h3>' . _prepare_html($v['head']) . '</h3>' : '') . ' ' . $v['body'] . '</div>' : '') . '
</div>
</' . $tag . '>';
}
$body = [];
$tag = $this->_is_bs3 ? 'div' : 'ul';
foreach (array_chunk($items, $columns) as $_items) {
$id = __FUNCTION__ . '_' . ++$this->_ids[__FUNCTION__];
$body[] = '<' . $tag . ' class="thumbnails' . ($extra['class'] ? ' ' . $extra['class'] : '') . '" id="' . $id . '">' . implode(PHP_EOL, (array) $_items) . '</' . $tag . '>';
}
return implode(PHP_EOL, $body);
}