getConf(InternalMediaLink::CONF_IMAGE_ENABLE, 1); if (!$enable) { // Inside a card, we need to take over and enable it $modes = [ PluginUtility::getModeForComponent(syntax_plugin_combo_card::TAG), ]; $enable = in_array($mode, $modes); } if ($enable) { $this->Lexer->addSpecialPattern(InternalMediaLink::INTERNAL_MEDIA_PATTERN, $mode, PluginUtility::getModeForComponent($this->getPluginComponent())); } } function handle($match, $state, $pos, Doku_Handler $handler) { switch ($state) { // As this is a container, this cannot happens but yeah, now, you know case DOKU_LEXER_SPECIAL : $media = InternalMediaLink::createFromRenderMatch($match); $attributes = $media->toCallStackArray(); $tag = new Tag(self::TAG, $attributes, $state, $handler); $parent = $tag->getParent(); $parentTag = ""; if (!empty($parent)) { $parentTag = $parent->getName(); if ($parentTag == syntax_plugin_combo_link::TAG) { /** * The image is in a link, we don't want another link * to the image */ $attributes[TagAttributes::LINKING_KEY] = InternalMediaLink::LINKING_NOLINK_VALUE; } } $isFirstSibling = $tag->isFirstMeaningFullSibling(); return array( PluginUtility::STATE => $state, PluginUtility::ATTRIBUTES => $attributes, PluginUtility::CONTEXT => $parentTag, self::IS_FIRST_IMAGE_KEY => $isFirstSibling ); } return array(); } /** * Render the output * @param string $format * @param Doku_Renderer $renderer * @param array $data - what the function handle() return'ed * @return boolean - rendered correctly? (however, returned value is not used at the moment) * @see DokuWiki_Syntax_Plugin::render() * * */ function render($format, Doku_Renderer $renderer, $data) { $attributes = $data[PluginUtility::ATTRIBUTES]; switch ($format) { case 'xhtml': /** @var Doku_Renderer_xhtml $renderer */ $attributes = $data[PluginUtility::ATTRIBUTES]; $media = InternalMediaLink::createFromCallStackArray($attributes, $renderer->date_at); if ($media->isImage()) { $renderer->doc .= $media->renderMediaTagWithLink(); } else { /** * This is not a media image (a video) * Dokuwiki takes over */ $src = $attributes['src']; $title = $attributes['title']; $align = $attributes['align']; $width = $attributes['width']; $height = $attributes['height']; $cache = $attributes['cache']; $linking = $attributes['linking']; $renderer->doc .= $renderer->internalmedia($src, $title, $align, $width, $height, $cache, $linking, true); } break; case "metadata": /** * Keep track of the metadata * @var Doku_Renderer_metadata $renderer */ self::registerImageMeta($attributes, $renderer); break; } // unsupported $mode return false; } /** * @param array $attributes * @param Doku_Renderer_metadata $renderer */ static public function registerImageMeta($attributes, $renderer) { $src = $attributes['src']; $title = $attributes['title']; $align = $attributes['align']; $width = $attributes['width']; $height = $attributes['height']; $cache = $attributes['cache']; // Cache: https://www.dokuwiki.org/images#caching $linking = $attributes['linking']; $renderer->internalmedia($src, $title, $align, $width, $height, $cache, $linking); } }