/** * Register method, called when the plugin is first registered. */ public function register() { /* * Register the image tag processing callback */ TagProcessor::instance()->registerCallback(function ($input, $preview) { if (!$preview) { return $input; } return preg_replace('|\\<img alt="([0-9]+)" src="image"([^>]*)\\/>|m', '<span class="image-placeholder" data-index="$1"> <span class="dropzone"> <span class="label">Click or drop an image...</span> <span class="indicator"></span> </span> <input type="file" class="file" name="image[$1]"/> <input type="file" class="trigger"/> </span>', $input); }); }
public static function formatHtml($input, $preview = false) { $result = Markdown::parse(trim($input)); if ($preview) { $result = str_replace('<pre>', '<pre class="prettyprint">', $result); } $result = TagProcessor::instance()->processTags($result, $preview); return $result; }