From 93a3b610d6120508daa429df1e6bc09ac50d5b42 Mon Sep 17 00:00:00 2001 From: SilverServersCopiliot <111811784+SilverServersCopiliot@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:39:26 -0700 Subject: [PATCH] Add image size support added the ability to set the size of an image in a backward compatible and optional way --- Parsedown.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Parsedown.php b/Parsedown.php index ae0cbde..3ef5217 100644 --- a/Parsedown.php +++ b/Parsedown.php @@ -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']);