1<?php
2
3namespace dokuwiki\plugin\gallery\classes;
4
5/**
6 * A gallery created from a list of images
7 */
8class ListGallery extends AbstractGallery
9{
10    /**
11     * @inheritdoc
12     * @param string[] $src
13     */
14    public function __construct($src, Options $options)
15    {
16        parent::__construct($src, $options);
17
18        foreach ($src as $item) {
19            [$img, $meta] = sexplode(' ', $item, 2);
20            [$title, $desc] = sexplode('|', $meta, 2);
21
22            $img = trim($img);
23            $title = trim($title);
24            $desc = trim($desc);
25
26            if (!$this->hasImageExtension($img)) continue;
27
28            try {
29                $image = new Image($img);
30            } catch (\Exception $e) {
31                // not found
32                continue;
33            }
34
35            if ($title) $image->setTitle($title);
36            if ($desc) $image->setDescription($desc);
37            $this->images[] = $image;
38        }
39    }
40}
41