diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js b/modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js index 60dcedab20..1406c37e13 100644 --- a/modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js +++ b/modules/ve-mw/dm/nodes/ve.dm.MWGalleryImageNode.js @@ -230,10 +230,11 @@ ve.dm.MWGalleryImageNode.static.toDomElements = function ( data, doc, converter while ( captionWrapper.firstChild ) { li.appendChild( captionWrapper.firstChild ); } + var captionText = ve.dm.MWGalleryImageNode.static.textContentFromCaption( li ).trim(); if ( img.nodeName.toLowerCase() === 'img' ) { - if ( attributes.altTextSame ) { - img.setAttribute( 'alt', ve.dm.MWGalleryImageNode.static.textContentFromCaption( li ).trim() ); + if ( attributes.altTextSame && captionText ) { + img.setAttribute( 'alt', captionText ); } else if ( typeof alt === 'string' ) { img.setAttribute( 'alt', alt ); } diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js index 007fe62eae..4418213c23 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWGalleryDialog.js @@ -671,7 +671,11 @@ ve.ui.MWGalleryDialog.prototype.onRequestImagesSuccess = function ( response ) { resource: title, altText: null, altTextSame: true, - href: null, + // TODO: support changing the link in the UI somewhere; + // for now, always link to the resource. Do it here when + // generating new results, so existing links from source + // will be preserved. + href: title, src: '', height: thumbUrls[ title ].height, width: thumbUrls[ title ].width,