Tim Starling has uploaded a new change for review.

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

Change subject: Add srcset attribute if imageinfo supplies it
......................................................................

Add srcset attribute if imageinfo supplies it

Bug: T88827
Change-Id: I426a7ed528cedfc29f2be90d25d4a73c8894ce7f
---
M lib/wt2html/tt/LinkHandler.js
M lib/wt2html/tt/Sanitizer.js
2 files changed, 12 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/47/249947/1

diff --git a/lib/wt2html/tt/LinkHandler.js b/lib/wt2html/tt/LinkHandler.js
index 4019bcc..cb1615d 100644
--- a/lib/wt2html/tt/LinkHandler.js
+++ b/lib/wt2html/tt/LinkHandler.js
@@ -1093,6 +1093,17 @@
                                }
                        }
                }
+
+               // Handle "responsive" images, i.e. srcset
+               if (info.responsiveUrls) {
+                       var density, candidates = [];
+                       for (density in info.responsiveUrls) {
+                               candidates.push(info.responsiveUrls[density] + 
' ' + density + 'x');
+                       }
+                       if (candidates.length > 0) {
+                               img.addAttribute('srcset', candidates.join(', 
'));
+                       }
+               }
        }
 
        if (size.height) {
diff --git a/lib/wt2html/tt/Sanitizer.js b/lib/wt2html/tt/Sanitizer.js
index 5228641..2a658f9 100644
--- a/lib/wt2html/tt/Sanitizer.js
+++ b/lib/wt2html/tt/Sanitizer.js
@@ -497,7 +497,7 @@
                                // Not usually allowed, but may be used for 
extension-style hooks
                                // such as <math> when it is rasterized, or if 
wgAllowImageTag is
                                // true
-                               'img': common.concat([ 'alt', 'src', 'width', 
'height' ]),
+                               'img': common.concat([ 'alt', 'src', 'width', 
'height', 'srcset' ]),
 
                                // 15.2.1
                                'tt':     common,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I426a7ed528cedfc29f2be90d25d4a73c8894ce7f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>

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

Reply via email to