From 1ce653c187153a6ed3182b863f37c5a2e8dcfb68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20PIERRE?= Date: Wed, 31 Mar 2021 21:57:30 +0200 Subject: [PATCH 1/2] img: add width and height MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This complies with HTML5 standards and let browser plan for the area to reserve to image before they load. If provided, it allows us to enable native browser lazy loading for performance. --- Michelf/Markdown.php | 8 ++++++++ Michelf/MarkdownExtra.php | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/Michelf/Markdown.php b/Michelf/Markdown.php index 9cf4c77..0f1e51b 100644 --- a/Michelf/Markdown.php +++ b/Michelf/Markdown.php @@ -864,6 +864,10 @@ protected function _doImages_reference_callback($matches) { if (isset($this->urls[$link_id])) { $url = $this->encodeURLAttribute($this->urls[$link_id]); $result = "\"$alt_text\"";titles[$link_id])) { $title = $this->titles[$link_id]; $title = $this->encodeAttribute($title); @@ -893,6 +897,10 @@ protected function _doImages_inline_callback($matches) { $alt_text = $this->encodeAttribute($alt_text); $url = $this->encodeURLAttribute($url); $result = "\"$alt_text\"";encodeAttribute($title); $result .= " title=\"$title\""; // $title already quoted diff --git a/Michelf/MarkdownExtra.php b/Michelf/MarkdownExtra.php index 462adab..b90f1b2 100644 --- a/Michelf/MarkdownExtra.php +++ b/Michelf/MarkdownExtra.php @@ -1030,6 +1030,10 @@ protected function _doImages_reference_callback($matches) { if (isset($this->urls[$link_id])) { $url = $this->encodeURLAttribute($this->urls[$link_id]); $result = "\"$alt_text\"";titles[$link_id])) { $title = $this->titles[$link_id]; $title = $this->encodeAttribute($title); @@ -1064,6 +1068,10 @@ protected function _doImages_inline_callback($matches) { $alt_text = $this->encodeAttribute($alt_text); $url = $this->encodeURLAttribute($url); $result = "\"$alt_text\"";encodeAttribute($title); $result .= " title=\"$title\""; // $title already quoted From 3bb3b6437daf33e5a02dee6cbb59522e6e664d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20PIERRE?= Date: Wed, 31 Mar 2021 22:12:41 +0200 Subject: [PATCH 2/2] check if file exists to prevent errors with tests --- Michelf/Markdown.php | 22 ++++++++++++++-------- Michelf/MarkdownExtra.php | 22 ++++++++++++++-------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Michelf/Markdown.php b/Michelf/Markdown.php index 0f1e51b..613ffe5 100644 --- a/Michelf/Markdown.php +++ b/Michelf/Markdown.php @@ -864,10 +864,13 @@ protected function _doImages_reference_callback($matches) { if (isset($this->urls[$link_id])) { $url = $this->encodeURLAttribute($this->urls[$link_id]); $result = "\"$alt_text\"";titles[$link_id])) { $title = $this->titles[$link_id]; $title = $this->encodeAttribute($title); @@ -897,10 +900,13 @@ protected function _doImages_inline_callback($matches) { $alt_text = $this->encodeAttribute($alt_text); $url = $this->encodeURLAttribute($url); $result = "\"$alt_text\"";encodeAttribute($title); $result .= " title=\"$title\""; // $title already quoted diff --git a/Michelf/MarkdownExtra.php b/Michelf/MarkdownExtra.php index b90f1b2..7868b5f 100644 --- a/Michelf/MarkdownExtra.php +++ b/Michelf/MarkdownExtra.php @@ -1030,10 +1030,13 @@ protected function _doImages_reference_callback($matches) { if (isset($this->urls[$link_id])) { $url = $this->encodeURLAttribute($this->urls[$link_id]); $result = "\"$alt_text\"";titles[$link_id])) { $title = $this->titles[$link_id]; $title = $this->encodeAttribute($title); @@ -1068,10 +1071,13 @@ protected function _doImages_inline_callback($matches) { $alt_text = $this->encodeAttribute($alt_text); $url = $this->encodeURLAttribute($url); $result = "\"$alt_text\"";encodeAttribute($title); $result .= " title=\"$title\""; // $title already quoted