jenkins-bot has submitted this change and it was merged.
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, 15 insertions(+), 1 deletion(-)
Approvals:
Subramanya Sastry: Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/wt2html/tt/LinkHandler.js b/lib/wt2html/tt/LinkHandler.js
index 4019bcc..cfe9a18 100644
--- a/lib/wt2html/tt/LinkHandler.js
+++ b/lib/wt2html/tt/LinkHandler.js
@@ -1093,6 +1093,20 @@
}
}
}
+
+ // Handle "responsive" images, i.e. srcset
+ if (info.responsiveUrls) {
+ var density;
+ var candidates = [];
+ for (density in info.responsiveUrls) {
+ candidates.push(
+
info.responsiveUrls[density].replace(/^https?:\/\//, '//') +
+ ' ' + 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: merged
Gerrit-Change-Id: I426a7ed528cedfc29f2be90d25d4a73c8894ce7f
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Tim Starling <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Subramanya Sastry <[email protected]>
Gerrit-Reviewer: Tim Starling <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits