Merge pull request #394 from bluebirch/fig_captions

Fig captions by @bluebirch
This commit is contained in:
Dan 2020-05-05 14:15:16 +07:00 committed by GitHub
commit 8ca4b3b625
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -360,6 +360,11 @@ function get_posts($posts, $page = 1, $perpage = 0)
// Get the contents and convert it to HTML
$post->body = MarkdownExtra::defaultTransform(remove_html_comments($content));
// Convert image tags to figures
if (config('fig.captions') == 'true') {
$post->body = preg_replace( '/<p>(<img .*?alt="(.*?)"\s*\/>)<\/p>/', '<figure>$1<figcaption>$2</figcaption></figure>', $post->body );
}
if (config('views.counter') == 'true') {
$post->views = get_views($post->file);
} else {