As mentioned by other people, you want to use a relative path for your files. However, that means that they won't normally show up when you're testing in Twine 2. Here's the trick to get around that:
(
Note: This assumes you're using the SugarCube 2 story format in Twine, which I would highly recommend.)
Code:
if (window.hasOwnProperty("storyFormat")) {
setup.Path = "C:/User/Home/Desktop/"; // Running inside Twine application
} else {
setup.Path = ""; // Running in a browser
}
setup.SoundPath = setup.Path + "sounds/";
setup.ImagePath = setup.Path + "pics/";
That code should be added to the top of your JavaScript section. (Change the above file path as necessary.)
Once you've done that you can use "setup.ImagePath" to display your images correctly, both in and out of Twine, using either of these methods:
Code:
[img[setup.ImagePath+'image.png']]
- or -
<img @src="setup.ImagePath+'image.png'">
(
Note: If you aren't using the latest version of SugarCube, currently
v2.27.0, I'd recommend
You must be registered to see the links
and
You must be registered to see the links
to the latest version since there've been a few improvements and bug fixes.)
Another thing to be careful of is capitalization. If the file is named "Xyz.jpg" and you try to display "xyz.jpg", then that will work in some browsers and operating systems, but not in others. I'd recommend renaming all of your images to lowercase, and only referring to them in lowercase, to avoid that problem. The same thing goes for the names of the directories (a.k.a. the file path) that you use.
Oh, and regarding Twine 2 embedding media, you really don't want to do that. "Embedding media" means encoding the images and other files into base64 format and building them into the HTML itself, which is usually a bad idea. Encoding them in base64 usually makes the files around 60% larger, and some browsers can't handle large HTML files. It's better to leave them as external files.
If you need help in the future you can try the "
You must be registered to see the links
" site or, if it includes some adult content, you might want to try the
You must be registered to see the links
You must be registered to see the links
in the "
You must be registered to see the links
" sub-forum.
Hope that helps, and have fun!