PHP code example of ammardev / commonmark-image-tools
1. Go to this page and download the library: Download ammardev/commonmark-image-tools library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ammardev / commonmark-image-tools example snippets
$environment = new Environment();
$environment->addExtension(new Ammardev\CommonMarkImageTools\ImageToolsExtension());
use Ammardev\CommonMarkImageTools\ImagePathManagerContract;
class ImagePathManager implements ImagePathManagerContract
{
/**
* This method will update the storage path that is used to get
* the image and extract width and height info.
*/
public function getImageStoragePath(string $originalSrc): string
{
return __DIR__ . '/storage/my-assets-folder/' . $originalSrc;
}
/**
* This method will update the public path that will be used in
* the src attribute.
*/
public function getImagePublicSrcPath(string $originalSrc): string
{
return '/public/assets/' . $originalSrc;
}
}