WebImageViewer not displaying from URL

I’m trying to load an image into a WebImageViewer (‘img_login_header_400x150’). The URLPath is valid, and loads fine when pasted into a browser. However the WebImageViewer never displays anything. I inspected the element in the browser and the div looks fine (pasted below). The Image isn’t inside any other control. TIA for pointing out any obvious mistakes on my part. Thanks!

Var f2 As New FolderItem(FilePath + FileName, FolderItem.PathModes.Native)

If f2 <> Nil Then
  If f2.Exists Then
    
    img_login_header_400x150.URL = f2.URLPath
    img_login_header_400x150.UpdateBrowser()
 
  End If
End If

<div tabindex="4" style="width: 100%; height: 100%; background-image: url(&quot;file:///Users/breynolds/...shortened.../LOGIN/visual_assets/lab_branding/1001/logo_header_login_400x150.png&quot;); opacity: 1; background-position: center center; background-size: auto; background-repeat: no-repeat; outline: none;"></div>

You need to make a webfile. And pass the url of that to the image viewer. The url of a folderitem won’t work in a browser.

Make a property of type WebFile, set the file to the folderitem.

2 Likes

Thanks @Greg_O , I’m still stuck, maybe you can see my next mistake :wink:

Var f2 As New FolderItem(FilePath + FileName, FolderItem.PathModes.Native)

Var WFile As WebFile = WebFile.Open(f2)
If WFile <> Nil Then 
  img_login_header_400x150.URL = WFile.URL
End If

…and here is the snippet from the page, not displaying the image…

<div tabindex="4" style="width: 100%; height: 100%; background-image: url(&quot;/EF0CB2105C87EED35F68E892E0E450479C7C44746C555889AE4B292EC996C1DC/files/7313-4119-5656-1114-8951/logo_header_login_400x150.png&quot;); opacity: 1; background-position: center center; background-size: auto; background-repeat: no-repeat; outline: none;"></div>

FWIW I’m not married to using WebImageViewer, if there’s a better way to dynamically display web images. This is a crucial part of the solution I’m working one; using branding images based on the nature of the user logging in. Thanks for any/all input on this. :slight_smile:

Add WFile as a property of the page and change the code to:

WFile = WebFile.Open(f2)

That did it!