avoid flickering img-responsives

This commit is contained in:
wgroeneveld 2020-06-07 11:00:42 +02:00
parent 98aaaece28
commit 0364e4b1bc
2 changed files with 2 additions and 6 deletions

View File

@ -27,11 +27,11 @@
<!-- thanks https://www.godo.dev/tutorials/hugo-image-figure-wrap/ -->
{{ $reAltIn := "<p><img src=\"([^\"]+)\" alt=\"([^\"]*)\" /></p>" }}
{{ $reAltOut := "<figure><a href=\"$1\" class=\"lbox\"><img src=\"$1\" alt=\"$2\"></a></figure>" }}
{{ $reAltOut := "<figure><a href=\"$1\" class=\"lbox\"><img class=\"img-responsive\" src=\"$1\" alt=\"$2\"></a></figure>" }}
{{ $altContent := .Content | replaceRE $reAltIn $reAltOut | safeHTML }}
{{ $reAltTitleIn := "<p><img src=\"([^\"]+)\" alt=\"([^\"]*)\" title=\"([^\"]+)\" /></p>" }}
{{ $reAltTitleOut := "<figure><a href=\"$1\" class=\"lbox\"><img src=\"$1\" title=\"$3\"></a><figcaption>$3</figcaption></figure>" }}
{{ $reAltTitleOut := "<figure><a href=\"$1\" class=\"lbox\"><img class=\"img-responsive\" src=\"$1\" title=\"$3\"></a><figcaption>$3</figcaption></figure>" }}
{{ $finalContent := $altContent | replaceRE $reAltTitleIn $reAltTitleOut | safeHTML }}
{{ $finalContent }}

View File

@ -1,15 +1,11 @@
$(function() {
var addResponsiveTagToContentImages = function() {
$("img").addClass("img-responsive");
};
var disableResponsiveImagesForInlineLis = function() {
$('li img.img-responsive').each(function() {
$(this).removeClass('img-responsive');
$(this).css('border', 'none');
});
};
addResponsiveTagToContentImages();
disableResponsiveImagesForInlineLis();
const box = new SimpleLightbox('.lbox', { /* options */ });