Skip to content

Commit

Permalink
Improved image parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
sal0max committed Jan 6, 2021
1 parent b2ba6df commit 20de209
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,8 @@

1. [](#improved)
* Updated GLightbox to 3.0.7
2. [](#improved)
* Improved image parsing

# v1.0.0
## 12/30/2020
Expand Down
10 changes: 8 additions & 2 deletions shortcodes/GalleryPlusPlusShortcode.php
Expand Up @@ -41,10 +41,16 @@ public function init()
// find all images, that a gallery contains
$content = $sc->getContent();

// check validity
if (str_contains($content, "<pre>"))
return "<p style='color: #d40000; font-weight: bold; padding: 1rem 0;'>[Shortcode Gallery++] Error:<br>
&gt; Images provided got parsed as code block.<br>
&gt; Please check your markdown file and make sure the images aren't indented by tab or more than three spaces.</p>";

// remove <p> tags
$content = preg_replace('(^\n?<p>|</p>$)', '', $content);
$content = preg_replace('(<p>|</p>)', '', $content);
// split up images to arrays of img links
preg_match_all('|<img.*/?>|', $content, $images);
preg_match_all('|<img.*?/>|', $content, $images);
// get all links
preg_match_all('|src="(.*?)"|', $content, $links);
// get all alt descriptions
Expand Down

0 comments on commit 20de209

Please sign in to comment.