Merge "Fix media embeds which don't link to the file page"

This commit is contained in:
jenkins-bot 2019-10-18 10:55:58 +00:00 committed by Gerrit Code Review
commit 416323bdca
2 changed files with 14 additions and 10 deletions

View file

@ -83,12 +83,14 @@ ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter
width = img.getAttribute( 'width' );
height = img.getAttribute( 'height' );
// Convert absolute URLs to relative if the href refers to a page on this wiki.
// Otherwise Parsoid generates |link= options for copy-pasted images (T193253).
href = imgWrapper.getAttribute( 'href' );
targetData = ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref( href, converter.getTargetHtmlDocument() );
if ( targetData.isInternal ) {
href = './' + targetData.title;
if ( href ) {
// Convert absolute URLs to relative if the href refers to a page on this wiki.
// Otherwise Parsoid generates |link= options for copy-pasted images (T193253).
targetData = ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref( href, converter.getTargetHtmlDocument() );
if ( targetData.isInternal ) {
href = './' + targetData.title;
}
}
// Ensure that resource and href are identical if they refer to the same page.
// https://www.mediawiki.org/w/?diff=931265&oldid=prev

View file

@ -64,12 +64,14 @@ ve.dm.MWInlineImageNode.static.toDataElement = function ( domElements, converter
width = img.getAttribute( 'width' ),
height = img.getAttribute( 'height' );
// Convert absolute URLs to relative if the href refers to a page on this wiki.
// Otherwise Parsoid generates |link= options for copy-pasted images (T193253).
href = imgWrapper.getAttribute( 'href' );
targetData = ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref( href, converter.getTargetHtmlDocument() );
if ( targetData.isInternal ) {
href = './' + targetData.title;
if ( href ) {
// Convert absolute URLs to relative if the href refers to a page on this wiki.
// Otherwise Parsoid generates |link= options for copy-pasted images (T193253).
targetData = ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref( href, converter.getTargetHtmlDocument() );
if ( targetData.isInternal ) {
href = './' + targetData.title;
}
}
// Ensure that resource and href are identical if they refer to the same page.
// https://www.mediawiki.org/w/?diff=931265&oldid=prev