public function get() { if (empty($this->src)) { if (empty($this->dummy)) { return ''; } $this->src = $this->dummy; } $options = ['class' => $this->_class, 'alt' => $this->template->replace($this->alt), 'title' => $this->title]; $src = $this->imageProvider->get($this->src, $this->w, $this->h); if (!((int) $this->const & ThumbInterface::WITHOUT_WIDTH_HEIGHT)) { $options['width'] = $this->imageProvider->width; $options['height'] = $this->imageProvider->height; } return (int) $this->const & ThumbInterface::OUTPUT_IMG ? Html::img($src, $options) : $src; }
/** * Parses an image indicated by `![`. * @marker ![ */ protected function parseImage($markdown) { if (($parts = $this->parseLinkOrImage(substr($markdown, 1))) !== false) { list($text, $url, $title, $offset, $key, $data) = $parts; if (isset($data['macros'])) { if ($this->isTag('thumb') && $data['macros'] === 'thumb') { if (!isset($this->imageProvider)) { if ($this->throwException) { throw new MarkdownException(MarkdownException::NOT_INSTALL_IMAGE); } return $this->skipImage($markdown); } } elseif ($this->isTag('video') && $data['macros'] !== 'thumb') { $width = isset($data['width']) ? $data['width'] : $this->dimensionsVideo[0]; $height = isset($data['height']) ? $data['height'] : $this->dimensionsVideo[1]; $video = $this->calculateVideo($url, $width, $height, $title ?: null); $video['refkey'] = $key; $video['orig'] = substr($markdown, 0, $offset + 1); $video['hosting'] = $data['macros']; return [$video, $offset + 1]; } } if (isset($this->imageProvider)) { $url = $this->imageProvider->get('/' . ltrim($url, '/'), Helper::getValue($data['width'], 0), Helper::getValue($data['height'], 0)); } return [['image', 'text' => $text, 'url' => $url, 'title' => $title, 'refkey' => $key, 'orig' => substr($markdown, 0, $offset + 1)], $offset + 1]; } else { return $this->skipImage($markdown); } }