Merge "Fix Gallery images always having |link=| and |alt=|"

This commit is contained in:
jenkins-bot 2023-11-28 20:17:32 +00:00 committed by Gerrit Code Review
commit 0ec1a7a2c0
2 changed files with 8 additions and 3 deletions

View file

@ -230,10 +230,11 @@ ve.dm.MWGalleryImageNode.static.toDomElements = function ( data, doc, converter
while ( captionWrapper.firstChild ) { while ( captionWrapper.firstChild ) {
li.appendChild( captionWrapper.firstChild ); li.appendChild( captionWrapper.firstChild );
} }
var captionText = ve.dm.MWGalleryImageNode.static.textContentFromCaption( li ).trim();
if ( img.nodeName.toLowerCase() === 'img' ) { if ( img.nodeName.toLowerCase() === 'img' ) {
if ( attributes.altTextSame ) { if ( attributes.altTextSame && captionText ) {
img.setAttribute( 'alt', ve.dm.MWGalleryImageNode.static.textContentFromCaption( li ).trim() ); img.setAttribute( 'alt', captionText );
} else if ( typeof alt === 'string' ) { } else if ( typeof alt === 'string' ) {
img.setAttribute( 'alt', alt ); img.setAttribute( 'alt', alt );
} }

View file

@ -671,7 +671,11 @@ ve.ui.MWGalleryDialog.prototype.onRequestImagesSuccess = function ( response ) {
resource: title, resource: title,
altText: null, altText: null,
altTextSame: true, 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: '', src: '',
height: thumbUrls[ title ].height, height: thumbUrls[ title ].height,
width: thumbUrls[ title ].width, width: thumbUrls[ title ].width,