From ceaf5923a226199be1396976f0dad32c8f884cf2 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 21 Jun 2020 03:34:05 +0200 Subject: [PATCH] helpers\ImageLazifier: use data attribute Use `data-selfoss-src` attribute instead of the invalid `ref` attribute. --- assets/js/lazy-image-loader.js | 2 +- src/helpers/ViewHelper.php | 4 ++-- tests/Helpers/ImageLazifierTest.php | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/assets/js/lazy-image-loader.js b/assets/js/lazy-image-loader.js index c6b66ee84f..9c559ce69b 100644 --- a/assets/js/lazy-image-loader.js +++ b/assets/js/lazy-image-loader.js @@ -6,7 +6,7 @@ import jQuery from 'jquery'; (function($) { $.fn.lazyLoadImages = function() { $(this).find('img').each(function(i, self) { - $(self).attr('src', $(self).attr('ref')); + $(self).attr('src', $(self).attr('data-selfoss-src')); }); }; })(jQuery); diff --git a/src/helpers/ViewHelper.php b/src/helpers/ViewHelper.php index fe0c4b2069..9c42c4f6e1 100644 --- a/src/helpers/ViewHelper.php +++ b/src/helpers/ViewHelper.php @@ -36,7 +36,7 @@ public static function highlight($content, $searchWords) { } /** - * removes img src attribute and saves the value in ref for + * removes img src attribute and saves the value in data attribute for * loading it later * * @param string $content which contains img tags @@ -68,7 +68,7 @@ public static function lazyimg($content) { $placeholder = "data:image/svg+xml;utf8,"; - return ""; + return ""; }, $content); } diff --git a/tests/Helpers/ImageLazifierTest.php b/tests/Helpers/ImageLazifierTest.php index f3416c37bd..9005b6d67f 100644 --- a/tests/Helpers/ImageLazifierTest.php +++ b/tests/Helpers/ImageLazifierTest.php @@ -14,7 +14,7 @@ public function testBasic() { EOD; $expected = << + EOD; $this->assertEquals( @@ -31,7 +31,7 @@ public function testWidthMissing() { EOD; $expected = << + EOD; $this->assertEquals( @@ -48,7 +48,7 @@ public function testHeightMissing() { EOD; $expected = << + EOD; $this->assertEquals( @@ -65,7 +65,7 @@ public function testDimensionsMissing() { EOD; $expected = << + EOD; $this->assertEquals(