webview_deno icon indicating copy to clipboard operation
webview_deno copied to clipboard

Cannot render local images

Open ovidiu141 opened this issue 3 years ago • 5 comments

Local images are not rendered - neither using absolute or relative paths

<img src="butter.png" alt="some issue" width="900" height="700">

Or am I doing something wrong?

ovidiu141 avatar Dec 17 '20 18:12 ovidiu141

there are no http server i guess. try to use one

panaC avatar Apr 14 '21 11:04 panaC

@panaC I was trying to avoid a server. I also tried using something like <img src="file:///home/me/butter.png" alt="some issue" width="900" height="700"> but I get: "CONSOLE SECURITY ERROR Not allowed to load local resource."

I don't see this as a security issue if you run deno with --allow-read

ovidiu141 avatar May 05 '21 16:05 ovidiu141

Why would it work for NW.js (https://github.com/nwjs/nw.js/issues/5499) but not for webview_deno?

ovidiu141 avatar May 24 '21 09:05 ovidiu141

@ovidiu141 this is just the way webview is implemented in the operating system. I'm using webview2 (Windows) directly from Rust:

image

image

There is sandbox etc. in front, you need server if you want it to be portable. Not all OS's allow to show file:// images in webview.

Edit There seems to be issue in Microsoft's webview2 repo to enable this: https://github.com/MicrosoftEdge/WebView2Feedback/issues/642

Ciantic avatar May 24 '21 13:05 Ciantic

So it looks like the fix is to set CoreWebView2EnvironmentOptions "--allow-file-access-from-files".

Webview takes an env_options when using WebView2 (windows), so maybe it can be sent when creating it.

Skhmt avatar Jul 27 '23 23:07 Skhmt