attributes = $attributes; $source = $medium->reset()->thumbnail('auto')->display('thumbnail'); if (!$source instanceof MediaObjectInterface) { throw new RuntimeException('Media has no thumbnail set'); } $source->set('linked', true); $this->source = $source; } /** * Get an element (is array) that can be rendered by the Parsedown engine * * @param string|null $title * @param string|null $alt * @param string|null $class * @param string|null $id * @param bool $reset * @return array */ public function parsedownElement($title = null, $alt = null, $class = null, $id = null, $reset = true) { $innerElement = $this->source->parsedownElement($title, $alt, $class, $id, $reset); return [ 'name' => 'a', 'attributes' => $this->attributes, 'handler' => is_array($innerElement) ? 'element' : 'line', 'text' => $innerElement ]; } /** * Forward the call to the source element * * @param string $method * @param mixed $args * @return mixed */ #[\ReturnTypeWillChange] public function __call($method, $args) { $object = $this->source; $callable = [$object, $method]; if (!is_callable($callable)) { throw new BadMethodCallException(get_class($object) . '::' . $method . '() not found.'); } $object = call_user_func_array($callable, $args); if (!$object instanceof MediaLinkInterface) { // Don't start nesting links, if user has multiple link calls in his // actions, we will drop the previous links. return $this; } $this->source = $object; return $object; } }