eberdna / commonmark-ext-prepend-image
Adds the possibility to prepend the image path/route
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:commononmark-extension
Requires
- league/commonmark: ^1.5
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-05-23 21:01:02 UTC
README
This adds support to prepend image path/routes to the league/commonmark package.
Install
composer require eberdna/commonmark-ext-prepend-image
Example
use League\CommonMark\Environment; use AndreBering\CommonMarkExtension\PrependImageExtension; $this->environment = Environment::createCommonMarkEnvironment(); $this->environment->addExtension(new PrependImageExtension('/path/to/files/')); $converter = new CommonMarkConverter([], $this->environment); $html = $converter->convertToHtml('![alt text](image.jpg)');
This creates the following HTML
<p><img src="/path/to/files/image.jpg" alt="alt text" /></p>
Please note that the path is only prepended if the markdown picture path does not start with '/'
, '//'
or 'http'
.
Options
There are no options for this extension. Only base path can set when creating the instance of PrependImageExtension
.