Page 1 of 1
HTML linking to referenced images
Posted: Fri Nov 06, 2020 1:06 am
by gsillevis
Hello!
I thought I would be clever and keep my filesize small by using referenced controls. But when I export the HTML5 and upload it, it doesn't take the images along. I'm sure there's an easy fix but I can't find it! Please help!
Re: HTML linking to referenced images
Posted: Fri Nov 06, 2020 12:41 pm
by Xero
How are you "referencing" your images?
If you are using relative paths, when you shift your app/HTML5, then the relative links won't go with it. If you're using absolute paths, then it should find it, as long as it has access to the link (i.e. if your path is linking to you hard-drive, and you're accessing your HTML5 online from a different computer, then it will look on the computer you're using, not the one you've stored them on.
Can you post some code here showing how you're referencing?
XdM
Re: HTML linking to referenced images
Posted: Fri Nov 06, 2020 1:21 pm
by elanorb
Hi
For standalones, including HTML5, you will need to include your resources in the Copy Files pane of the Standalone Application Settings and then ensure the references you are using are correct. These can be relative or absolute paths, using specialFolderPath("resources") is often the easiest way to build the paths to the files in a standalone.
I hope that helps.
Elanor
Re: HTML linking to referenced images
Posted: Fri Nov 06, 2020 2:19 pm
by gsillevis
I realised that I was referencing the absolute paths. What is the easiest way to change them all?
Currently theyre in
C:\Users\XXX\Dropbox\Game\LiveCode files\General\example.png
I've started going through by hand and changing the files to relative paths
\General\example.png
Is there a script that can do it all at once? And where/how do I implement it?
Thank you!
Re: HTML linking to referenced images
Posted: Fri Nov 06, 2020 3:06 pm
by gsillevis
elanorb wrote: ↑Fri Nov 06, 2020 1:21 pm
Hi
For standalones, including HTML5, you will need to include your resources in the Copy Files pane of the Standalone Application Settings and then ensure the references you are using are correct. These can be relative or absolute paths, using specialFolderPath("resources") is often the easiest way to build the paths to the files in a standalone.
I hope that helps.
Elanor
Can you help me figure out specialFolderPath("resources")? I can't seem to make heads or tails of it.
Re: HTML linking to referenced images
Posted: Fri Nov 06, 2020 7:33 pm
by elanorb
Hi
The specialFolderPath("resources") function will give you the path to the folder that contains the resources you included in the Copy Files pane. You can use this to set the paths to the images etc. You could do this in preOpenStack or preOpenCard e.g.
Code: Select all
on preOpenCard
set the filename of image "example" to (specialFolderPath("resources") & "/General/example.png")
... do the rest of the images
end preOpenCard
I hope that helps.
Kind regards
Elanor
Re: HTML linking to referenced images
Posted: Fri Nov 06, 2020 7:43 pm
by richmond62
All the above sounds so complicated I would just import them into the stack.

Re: HTML linking to referenced images
Posted: Sat Nov 07, 2020 7:04 pm
by jacque
richmond62 wrote: ↑Fri Nov 06, 2020 7:43 pm
All the above sounds so complicated I would just import them into the stack.
It isn't really. Think of specialFolderPath as a variable holding a path to specific folder. That's all it is, and LC does the work for you figuring out where that folder is on every OS.