mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Merge "Fix Parsoid HTML of broken images"
This commit is contained in:
commit
8e5af5aafd
|
@ -168,7 +168,7 @@ ve.dm.MWBlockImageNode.static.toDomElements = function ( data, doc, converter )
|
|||
mediaClass = dataElement.attributes.mediaClass,
|
||||
figure = doc.createElement( 'figure' ),
|
||||
imgWrapper = doc.createElement( dataElement.attributes.href ? 'a' : 'span' ),
|
||||
img = doc.createElement( this.typesToTags[ mediaClass ] ),
|
||||
img = doc.createElement( dataElement.attributes.isError ? 'span' : this.typesToTags[ mediaClass ] ),
|
||||
wrapper = doc.createElement( 'div' ),
|
||||
classAttr = this.getClassAttrFromAttributes( dataElement.attributes ),
|
||||
captionData = data.slice( 1, -1 );
|
||||
|
@ -202,12 +202,14 @@ ve.dm.MWBlockImageNode.static.toDomElements = function ( data, doc, converter )
|
|||
}
|
||||
|
||||
srcAttr = this.typesToSrcAttrs[ mediaClass ];
|
||||
if ( srcAttr ) {
|
||||
if ( srcAttr && !dataElement.attributes.isError ) {
|
||||
img.setAttribute( srcAttr, dataElement.attributes.src );
|
||||
}
|
||||
// TODO: This does not make sense for broken images (when img is a span node)
|
||||
img.setAttribute( 'width', width );
|
||||
img.setAttribute( 'height', height );
|
||||
img.setAttribute( 'resource', dataElement.attributes.resource );
|
||||
// TODO: This does not make sense for broken images (when img is a span node)
|
||||
if ( typeof dataElement.attributes.alt === 'string' ) {
|
||||
img.setAttribute( 'alt', dataElement.attributes.alt );
|
||||
}
|
||||
|
|
|
@ -149,16 +149,18 @@ ve.dm.MWInlineImageNode.static.toDomElements = function ( data, doc ) {
|
|||
var firstChild, srcAttr,
|
||||
mediaClass = data.attributes.mediaClass,
|
||||
container = doc.createElement( data.attributes.tagName || 'span' ),
|
||||
img = doc.createElement( this.typesToTags[ mediaClass ] ),
|
||||
img = doc.createElement( data.attributes.isError ? 'span' : this.typesToTags[ mediaClass ] ),
|
||||
classes = [],
|
||||
originalClasses = data.attributes.originalClasses;
|
||||
|
||||
// TODO: This does not make sense for broken images (when img is a span node)
|
||||
ve.setDomAttributes( img, data.attributes, [ 'width', 'height', 'resource' ] );
|
||||
srcAttr = this.typesToSrcAttrs[ mediaClass ];
|
||||
if ( srcAttr ) {
|
||||
if ( srcAttr && !data.attributes.isError ) {
|
||||
img.setAttribute( srcAttr, data.attributes.src );
|
||||
}
|
||||
|
||||
// TODO: This does not make sense for broken images (when img is a span node)
|
||||
if ( typeof data.attributes.alt === 'string' ) {
|
||||
img.setAttribute( 'alt', data.attributes.alt );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue