Mholloway has uploaded a new change for review.

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

Change subject: Fix fixVideoAnchor
......................................................................

Fix fixVideoAnchor

Stop stripping the data-file-type attribute from img tags so that the video
anchor transform actually runs.

Removes code to strip the internal link prefix from video links in the
fixVideoAnchor() func in lib/tranformations/anchorPopUpMediaTransforms.js.
Any needed manipulation is done on the client so it's redundant here.

Bug: T140905
Change-Id: I1a1fe857eec95f176d835fc92515955f56c3bd62
Depends-On: I3a7eceb55051adf3f40cd583ef2d661141894236
---
M lib/transformations/anchorPopUpMediaTransforms.js
M lib/transforms.js
2 files changed, 6 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps 
refs/changes/24/311824/1

diff --git a/lib/transformations/anchorPopUpMediaTransforms.js 
b/lib/transformations/anchorPopUpMediaTransforms.js
index f5fe7e1..6474d4c 100644
--- a/lib/transformations/anchorPopUpMediaTransforms.js
+++ b/lib/transformations/anchorPopUpMediaTransforms.js
@@ -11,16 +11,12 @@
 'use strict';
 
 function fixVideoAnchor(content) {
-       var videoThumbImgElements = content.querySelectorAll( 'a[href] > 
img[data-file-type="video"]' );
-       for ( var i = 0; i < videoThumbImgElements.length; i++ ) {
-               var containerLink = videoThumbImgElements[i].parentNode;
-               var referenceValue = containerLink.getAttribute('href');
-               referenceValue = referenceValue.replace(/^\.\//, ''); // so it 
doesn't get the "/wiki" prefix
-        containerLink.setAttribute( 'href', referenceValue );
-        containerLink.classList.add( 'app_media' );
-       }
+    var videoThumbImgElements = content.querySelectorAll('a[href] > 
img[data-file-type="video"]');
+    for (var i = 0; i < videoThumbImgElements.length; i++) {
+        videoThumbImgElements[i].parentNode.classList.add('app_media');
+    }
 }
 
 module.exports = {
-       fixVideoAnchor: fixVideoAnchor
+    fixVideoAnchor: fixVideoAnchor
 };
diff --git a/lib/transforms.js b/lib/transforms.js
index dd90e40..fb74fa7 100644
--- a/lib/transforms.js
+++ b/lib/transforms.js
@@ -154,7 +154,7 @@
     _rmAttributes(doc, 'figcaption a[class~=image]', ['class']); // T123527
     _rmAttributes(doc, 'i', ['about', 'data-mw', 'id', 'typeof']);
     _rmAttributes(doc, 'li', ['about']);
-    _rmAttributes(doc, 'img', ['alt', 'data-file-height', 'data-file-type', 
'data-file-width', 'id', 'resource']);
+    _rmAttributes(doc, 'img', ['alt', 'data-file-height', 'data-file-width', 
'id', 'resource']);
     _rmAttributes(doc, 'span', ['about', 'data-file-type', 'data-mw', 'id', 
'itemscope', 'itemtype', 'lang', 'rel',
         'title', 'typeof']);
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1a1fe857eec95f176d835fc92515955f56c3bd62
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <mhollo...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to