Skip to content

Commit a17a120

Browse files
committed
use fetchId and fetch:// for inline images
The content-ID may be not defined for inline parts.
1 parent e453faf commit a17a120

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/src/dom/image_transformers.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,17 @@ class ImageTransformer implements DomTransformer {
7070
message.findContentInfo(disposition: ContentDisposition.inline);
7171

7272
for (final info in inlineInfos) {
73+
//TODO inline elements should be added at their respective positions and not necessary below the text
7374
if (info.isImage) {
7475
final cid = info.cid;
75-
if (!usedContentIds.contains(cid)) {
76-
final part = message.getPart(info.fetchId)!;
77-
final data = toImageData(part, info.mediaType, configuration);
78-
final imageElement = Element.html(
79-
'<a href="cid://$cid"><img src="$data" alt="${info.fileName}" /></a>');
80-
document.body!.append(imageElement);
76+
if (cid == null || !usedContentIds.contains(cid)) {
77+
final part = message.getPart(info.fetchId);
78+
if (part != null) {
79+
final data = toImageData(part, info.mediaType, configuration);
80+
final imageElement = Element.html(
81+
'<a href="fetch://${info.fetchId}"><img src="$data" alt="${info.fileName}" /></a>');
82+
document.body!.append(imageElement);
83+
}
8184
}
8285
}
8386
}

0 commit comments

Comments
 (0)