Add image size support

added the ability to set the size of an image in a backward compatible and optional way
This commit is contained in:
SilverServersCopiliot 2023-08-02 14:39:26 -07:00 committed by GitHub
parent 6598f3860c
commit 93a3b610d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -1378,6 +1378,12 @@ class Parsedown
),
);
//get width and height from href attribute if exists (ex: "http://www.example.com/image.png#100x100")
if (preg_match('/^(.*)#(\d+)x(\d+)$/', $Link['element']['attributes']['href'], $matches)) {
if(isset($matches[2])) $Inline['element']['attributes']['width'] = $matches[2];
if(isset($matches[3])) $Inline['element']['attributes']['height'] = $matches[3];
}
$Inline['element']['attributes'] += $Link['element']['attributes'];
unset($Inline['element']['attributes']['href']);