Skip to content

Commit 378b93d

Browse files
committed
2 parents 1d28096 + 3cd209b commit 378b93d

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

lib/src/dom/image_transformers.dart

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ class ImageTransformer extends DomTransformer {
6969
imageElement.attributes['src'] = 'https:$url';
7070
}
7171
}
72+
} // src != null
73+
final style = imageElement.attributes['style'];
74+
if (style == null) {
75+
imageElement.attributes['style'] = 'max-width: 100%;';
76+
} else if (!style.contains('max-width')) {
77+
imageElement.attributes['style'] = '$style max-width: 100%;';
7278
}
7379
}
7480
// integrate other inline images:
@@ -85,8 +91,11 @@ class ImageTransformer extends DomTransformer {
8591
if (part != null) {
8692
final data = toImageData(part, info.mediaType, configuration);
8793
final imageElement = Element.html(
88-
'<a href="fetch://${info.fetchId}"><img src="$data" alt="${info.fileName}" /></a>');
89-
document.body!.append(imageElement);
94+
'<a href="fetch://${info.fetchId}">'
95+
'<img src="$data" alt="${info.fileName}" />'
96+
'</a>',
97+
);
98+
document.body?.append(imageElement);
9099
}
91100
}
92101
}

0 commit comments

Comments
 (0)