public function testProcessImageHtml() { $this->assertRegexp('|<img alt="Sample Image" src="\\/images\\/.*-sample-image.jpe?g\\" data-src="sample-image\\.jpg\\?cropZoom=300,300" \\/>|', Excerpts::processImageHtml('<img src="sample-image.jpg?cropZoom=300,300" alt="Sample Image" />', $this->page)); $this->assertRegexp('|<img alt="Sample Image" class="foo" src="\\/images\\/.*-sample-image.jpe?g\\" data-src="sample-image\\.jpg\\?classes=foo" \\/>|', Excerpts::processImageHtml('<img src="sample-image.jpg?classes=foo" alt="Sample Image" />', $this->page)); }
protected function inlineLink($excerpt) { if (isset($excerpt['type'])) { $type = $excerpt['type']; } else { $type = 'link'; } // do some trickery to get around Parsedown requirement for valid URL if its Twig in there if (preg_match($this->twig_link_regex, $excerpt['text'], $matches)) { $excerpt['text'] = str_replace($matches[1], '/', $excerpt['text']); $excerpt = parent::inlineLink($excerpt); $excerpt['element']['attributes']['href'] = $matches[1]; $excerpt['extent'] = $excerpt['extent'] + strlen($matches[1]) - 1; return $excerpt; } else { $excerpt = parent::inlineLink($excerpt); } // if this is a link if (isset($excerpt['element']['attributes']['href'])) { $excerpt = Excerpts::processLinkExcerpt($excerpt, $this->page, $type); } return $excerpt; }