HTML linking to referenced images

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
gsillevis
Posts: 38
Joined: Tue Oct 13, 2020 10:55 pm

HTML linking to referenced images

Post by gsillevis » Fri Nov 06, 2020 1:06 am

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!

Xero
Posts: 89
Joined: Sat Jun 23, 2018 2:22 pm

Re: HTML linking to referenced images

Post by Xero » Fri Nov 06, 2020 12:41 pm

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

elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 456
Joined: Fri Feb 24, 2006 9:45 am

Re: HTML linking to referenced images

Post by elanorb » 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
Elanor Buchanan
Software Developer
LiveCode

gsillevis
Posts: 38
Joined: Tue Oct 13, 2020 10:55 pm

Re: HTML linking to referenced images

Post by gsillevis » Fri Nov 06, 2020 2:19 pm

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!

gsillevis
Posts: 38
Joined: Tue Oct 13, 2020 10:55 pm

Re: HTML linking to referenced images

Post by gsillevis » Fri Nov 06, 2020 3:06 pm

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.

elanorb
Livecode Staff Member
Livecode Staff Member
Posts: 456
Joined: Fri Feb 24, 2006 9:45 am

Re: HTML linking to referenced images

Post by elanorb » Fri Nov 06, 2020 7:33 pm

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
Elanor Buchanan
Software Developer
LiveCode

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5412
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: HTML linking to referenced images

Post by richmond62 » Fri Nov 06, 2020 7:43 pm

All the above sounds so complicated I would just import them into the stack. 8)

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5861
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: HTML linking to referenced images

Post by jacque » Sat Nov 07, 2020 7:04 pm

richmond62 wrote:
Fri Nov 06, 2020 7:43 pm
All the above sounds so complicated I would just import them into the stack. 8)
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”