0 votes
by (160 points)
Hello all ! I am currently putting images in my story and I am wandering, if I enter my file path (for example C:\\TwineProject:\\image.jpg) then when I upload the whole folder containing the html file + my images folder and someone downloads it, well the path to the images will not be the same and the code in the html file will remain unchanged, so the path written in the html file will be false, right ? So my question is, can you get (with some manipulation, some code) the path to the TwineProject folder inside Twine ? If not, how can I do so my images will remain either way it's on my computer or on another one ?

Sorry for this question may have been answerd a million times already but I do not seem to find this particular question.

1 Answer

+1 vote
by (63.1k points)
selected by
 
Best answer
You can (and should) use relative URLs. For example, if the html file is bundled with a folder called "images" containing an image named "my-image.jpg", the relative URL would be "./images/my-image.jpg".

https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL#Absolute_URLs_vs_relative_URLs
by (160 points)
Well thanks a lot ! :)
by (160 points)
Okay so it does not seem to work, I think I tried everything: using slashes, backslashes, changing the starting folder, the starting of the path (./, /, no /, folder/). I also tried having my picture in the same folder as the html file. And I tried using the sugarcube way of showing images ([img[img.png]]). And nothing worked, ah yes ! The only thing that worked is when I gave the entire path (exactly what I do not want to do). I don't want to get my images on internet because I have to store them online, on a public website, and who knows how much time the storing will last. I saw you can use macros but it seems a little difficult maybe, I don't know, tell me about it if you think it is affordable.
by (63.1k points)
How did you test it? Did you publish the story to a file or use Twine 2's test or play features. That latter cannot support relative paths because the file is run from memory, not from the disk.
by (160 points)
Indeed, running the file through Twine was the problem, I tried running it directly with the html file and it works a lot better x) Thanks again ! I hope you have a great day :)
by (63.1k points)
Okay great. I forgot to mention that little hiccup.
...