Skip to content

Commit

Permalink
use fetchId and fetch:// for inline images
Browse files Browse the repository at this point in the history
The content-ID may be not defined for inline parts.
  • Loading branch information
robert-virkus committed Apr 15, 2021
1 parent e453faf commit a17a120
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/src/dom/image_transformers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,17 @@ class ImageTransformer implements DomTransformer {
message.findContentInfo(disposition: ContentDisposition.inline);

for (final info in inlineInfos) {
//TODO inline elements should be added at their respective positions and not necessary below the text
if (info.isImage) {
final cid = info.cid;
if (!usedContentIds.contains(cid)) {
final part = message.getPart(info.fetchId)!;
final data = toImageData(part, info.mediaType, configuration);
final imageElement = Element.html(
'<a href="cid://$cid"><img src="$data" alt="${info.fileName}" /></a>');
document.body!.append(imageElement);
if (cid == null || !usedContentIds.contains(cid)) {
final part = message.getPart(info.fetchId);
if (part != null) {
final data = toImageData(part, info.mediaType, configuration);
final imageElement = Element.html(
'<a href="fetch://${info.fetchId}"><img src="$data" alt="${info.fileName}" /></a>');
document.body!.append(imageElement);
}
}
}
}
Expand Down

0 comments on commit a17a120

Please sign in to comment.