noahlange / homebrewery-electron

Electron port of Natural Crit's Homebrewery app.
10 stars 6 forks source link

Including local files via an absolute path #12

Closed TheWatchingI closed 2 years ago

TheWatchingI commented 2 years ago

Hello,

I've downloaded the offline release of the Homebrewery here https://github.com/noahlange/homebrewery-electron/releases ( homebrewery-setup-1.0.5.exe )

The example page explains that to include images you either have to provide a link or an absolute path to a local file. I've got the links working, but not the absolute paths:

![here](https://i.imgur.com/hMna6G0.png) -> Works

![here](E:\test.png) or ![here]("E:\test.png") -> Doesn't work

Can you, @noahlange , or somebody else give me an example, how to include a file via an absolute path?

noahlange commented 2 years ago

This could very well be is probably a "Noah didn't test backslashes on Windows" issue.

You might be able to start with the file:/// protocol and load it that way, but I haven't touched this in years and honestly don't remember.

I'll take a gander. If there's an obvious fix, I'll take a shot at patching it.

noahlange commented 2 years ago

All righty: due to the way electron webviews load images, you'll need to:

  1. replace all backslashes ("\") in the path with forward slashes ("/")
  2. prefix any absolute paths with a "/"
  3. omit quotes

Example:

If you open the developer tools, you can inspect the element in the DOM to see precisely which file it's attempting to load.

TheWatchingI commented 2 years ago

Thank you, that works like a charm!

One last question, if you have the time: Do you know if it is possible to include paths with a space? ![here](/E:/New Directory/test.png) -> doesn't work because of the space