xref: /plugin/combo/ComboStrap/ImageLink.php (revision 1fa8c418ed5809db58049141be41b7738471dd32)
1<?php
2
3
4namespace ComboStrap;
5
6
7/**
8 * Class ImageLink
9 * @package ComboStrap
10 *
11 * A media of image type
12 */
13abstract class ImageLink extends MediaLink
14{
15
16
17    function getDefaultImage(): Image
18    {
19        if (!($this->getMedia() instanceof Image)) {
20            LogUtility::msg("The media ($this) is not an image", LogUtility::LVL_MSG_ERROR);
21        }
22        /** @noinspection PhpIncompatibleReturnTypeInspection */
23        return $this->getMedia();
24    }
25
26    /**
27     * @return string the wiki syntax
28     */
29    public function getMarkupSyntax(): string
30    {
31        $descriptionPart = "";
32        if (!empty($this->getDefaultImage()->getAltNotEmpty())) {
33            $descriptionPart = "|" . $this->getDefaultImage()->getAltNotEmpty();
34        }
35        return '{{' . $this->getMedia()->getAbsolutePath() . $descriptionPart . '}}';
36    }
37
38}
39