Hi, Readers.
We briefly discussed how to how to preview Base64 string image within BC (Base64 Image Viewer) before. More details: How to preview Base64 string image within BC (Base64 Image Viewer).
We used the standard WebPageViewer add-in to display an image in HTML.
<img src="img_girl.jpg" alt="Girl in a jacket" width="500" height="600">The <img> tag is used to embed an image in an HTML page. The HTML Image src attribute of the image can be inserted after src to display it directly.
A simple test:
We customized a new method before.
In fact, there is a standard method for obtaining HTML Image src attribute directly in BC.
codeunit 4112 “Image Helpers” -> procedure GetHTMLImgSrc:
Let’s look at a simple example, get the HTML Image src attribute of the image of the currently opened item.
Test video:
Source code: Github (Please note that the source code is for reference only, you can improve it according to your own needs)
pageextension 50120 ItemCardExt extends "Item Card"
{
actions
{
addafter(CopyItem)
{
action(GetHTMLImgSrcFromItemPicture)
{
Caption = 'Get HTML Image src attribute';
ApplicationArea = All;
Promoted = true;
PromotedCategory = Process;
PromotedIsBig = true;
Image = GetSourceDoc;
trigger OnAction()
var
ImageHelpers: Codeunit "Image Helpers";
ItemPictureInStream: InStream;
ItemTenantMedia: Record "Tenant Media";
begin
if Rec.Picture.Count > 0 then begin
ItemTenantMedia.Get(Rec.Picture.Item(1));
ItemTenantMedia.CalcFields(Content);
ItemTenantMedia.Content.CreateInStream(ItemPictureInStream, TextEncoding::UTF8);
Message(ImageHelpers.GetHTMLImgSrc(ItemPictureInStream));
end;
end;
}
}
}
}Great, give it a try!!!😁
END
Hope this will help.
Thanks for reading.
ZHU
コメント