Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/275670

Change subject: Use the src attribute Luke
......................................................................

Use the src attribute Luke

There is no need to use the image inside the noscript tag.
This passes the alt+src attribute onto the placeholder
and uses them in construction.

This does increase HTML size, but this will be swallowed in gzip
compression and this avoids issues with escaping.

Bug: T126593
Change-Id: I37a71d6dff34f0cd70d79d35941b4afe1cea72bf
---
M includes/MobileFormatter.php
M resources/mobile.startup/Skin.js
2 files changed, 3 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/70/275670/1

diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php
index 95ea015..35da51e 100644
--- a/includes/MobileFormatter.php
+++ b/includes/MobileFormatter.php
@@ -159,6 +159,7 @@
                        $imgPlaceholder = $doc->createElement( 'span' );
                        $imgPlaceholder->setAttribute( 'class', 
'lazy-image-placeholder' );
                        $imgPlaceholder->setAttribute( 'style', 
$dimensionsStyle );
+                       $imgPlaceholder->setAttribute( 'data-src', 
$img->getAttribute( 'src' ) );
                        $imgPlaceholder->appendChild( $spinner );
 
                        // Set the placeholder where the original image was
diff --git a/resources/mobile.startup/Skin.js b/resources/mobile.startup/Skin.js
index dd4dc37..c23371a 100644
--- a/resources/mobile.startup/Skin.js
+++ b/resources/mobile.startup/Skin.js
@@ -217,10 +217,10 @@
                 * @param {jQuery.Object} $placeholder
                 */
                loadImage: function ( $placeholder ) {
-                       var $noscript = $placeholder.prev( 'noscript' ),
+                       var src = $placeholder.data( 'src' ),
                                // Grab the image markup from the HTML only 
fallback
                                // Image will start downloading
-                               $image = $( $.parseHTML( $noscript.text() ) ),
+                               $image = $( '<img>' ).attr( 'src', src ),
                                $downloadingImage = $( '<img/>' );
 
                        // When the image has loaded

-- 
To view, visit https://gerrit.wikimedia.org/r/275670
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I37a71d6dff34f0cd70d79d35941b4afe1cea72bf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to