aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-06-21 18:40:06 +0200
committerThomas Lange <code@nerdmind.de>2021-06-21 18:40:06 +0200
commit55eaa1d7b47d11078bd441427cfe16483cf966f7 (patch)
treea8323a0aafb663a15713c80c201cf46c1f581e01
parent3c1f5e3427e3e45a11b772dfe24da2cef63f91f0 (diff)
downloadblog-55eaa1d7b47d11078bd441427cfe16483cf966f7.tar.gz
blog-55eaa1d7b47d11078bd441427cfe16483cf966f7.tar.xz
blog-55eaa1d7b47d11078bd441427cfe16483cf966f7.zip
Add function getMarkdownImageURLs
-rw-r--r--core/functions.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/functions.php b/core/functions.php
index 7157e03..4befb19 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -186,6 +186,20 @@ function parseEntityContent(Item $Item): string {
}
#===============================================================================
+# Extract Markdown formatted image URLs
+#===============================================================================
+function getMarkdownImageURLs(string $text): array {
+ $pattern = '#\!\[(.*)\][ ]?(?:\n[ ]*)?\((.*)(\s[\'"](.*)[\'"])?\)#U';
+ $content = parseContentTags($text);
+
+ if(preg_match_all($pattern, $content, $matches)) {
+ return array_map('htmlentities', $matches[2]);
+ }
+
+ return [];
+}
+
+#===============================================================================
# Parser for datetime formatted strings [YYYY-MM-DD HH:II:SS]
#===============================================================================
function parseDatetime($datetime, $format): string {