<?php
final class CustomInlineImageRule extends PhabricatorRemarkupCustomInlineRule {
public function getPriority() {
return 200.0; // Must be lower than 300 to over URL detection
}
public function apply($text) {
return preg_replace_callback(
'(<img (.*?)>)s',
array($this, 'markupInlineImageBlock'),
$text);
}
public function markupInlineImageBlock($matches) {
$engine = $this->getEngine();
$text = $matches[1];
$element = new SimpleXMLElement("<element $text />");
$attributes = array();
foreach($element->attributes() as $k => $v) {
$attributes[$k] = $v;
}
$source_body = phutil_tag('img', $attributes);
return $engine->storeText($source_body);
}
}