Your base64 approach is the right one. I loaded the exact markup your code produces into the HTMLViewer's underlying web engines and it renders correctly, so you're close. There are three small problems in the details and one size limit to watch for.
Why the file path version can't work
A document loaded with LoadHTML cannot read local files. The web view gives it a blank internal origin, so <img src='C:\Photos\Thumbnails\X.jpg'> is not a valid reference, and even a proper file:/// URL is blocked by the web view's security rules for string-loaded documents. That's standard web view security rather than something Objo can switch off, and it's exactly why the base64 data URI approach exists.
Fixing the base64 version
Three corrections:
- The MIME type for JPEG is
image/jpeg, not image/jpg.
WIDTH=200px isn't valid there - the HTML width/height attributes take a plain number with no px, so use 200.
- You can drop
Chr(34): inside an Objo string, a doubled "" produces a single quote character.
Putting that together:
Var t_ImageName As String = App.g_ImagePath + "/Thumbnails/" + img_value + ".jpg"
If FileSystemItem.Exists(t_ImageName) Then
Var file As FileSystemItem = New FileSystemItem(t_ImageName)
Var img As Picture = New Picture(t_ImageName)
Var t_size As String
If img.Width > img.Height Then
t_size = "width=""200"""
ElseIf img.Width < img.Height Then
t_size = "height=""200"""
Else
t_size = "width=""200"" height=""200"""
End If
Var imgbase64 As String = file.ReadAllBytes().ToBase64()
image_portion = "<center><img src=""data:image/jpeg;base64," + imgbase64 + """ alt=""" + img_value + ".jpg"" class=""cImage"" " + t_size + "></center><br>"
End If
Then load the assembled document with HTMLViewer1.LoadHTML(doc).
Also note that base64String is declared twice in your code - the inner declaration shadows the outer one (that's the compiler warning you may have noticed) and the outer one is never used, so it can simply be deleted.
Watch the total document size on Windows
You're embedding the entire JPEG as base64 and only constraining the displayed size with width/height. Base64 inflates the data by about a third, and on Windows the underlying WebView2 engine refuses LoadHTML documents over about 2 MB in total - a large photo will take the whole document over that limit even though it displays at 200 px. Since these are thumbnails, embed genuinely small thumbnail files rather than full-size photos. I have this Windows limit on our list to work around in a future release (https://feedback.objo.dev/bug/1522).
If it still doesn't display after those changes, let me know which platform you're on and what HTMLViewer1.LastError says immediately after the LoadHTML call - that will pinpoint what's left.