Obtaining image URL for embeded images

I need a way to be able to get the URL for images that are embedded within Xojo in a web project. Can anyone suggest how I can do this.

What about looking at the page source through a browser ?

Granted that Web is not my forte, but what do you mean, “embedded within Xojo”? You mean images you included in your project, or something else?

I need to do it on app open so that is too late

Kem, yes the ones added via the IDE.

If I look using Firebug the URL is:

http://127.0.0.1:8090/23AE355511A531821A50236FDB509C7B/files/{2268-7003-7339-5374-3030}/icon-admin.png

What is it that you plan to do with the url?

I want to be able to dynamically create the appcache file so that when my project is used on a mobile device it will store images etc on the device making it more responsive.

Now you’re outside my expertise, but I wonder if this is necessary. Perhaps someone with more experience can weigh in.

The need is that if you get your appcache set correctly then it makes the project far more responsive and reduces the bandwidth / data usage on the mobile network, the main reason is that you preload all the images which also reduces flicker and makes the whole user experience much better. If you get it wrong then the appcache can really bite you on the butt!

If we break it down to something simple…

Can someone give me an example of how to create a loop that gets a list of web pages within the project and then for each page loops through each control. Based on that I think I can then do the rest.

Yes, I got that, but what I was wondering is if Xojo does this for you already. It would save you a lot of work if it does.

It could but I dont see how it can because what goes in the appcache has to be very carefully handled otherwise it can cause a total mess and you can be scratching your head for hours. Also based on what I have see with images loading I and 99% sure it doesnt. It would be brilliant if it did and would not be difficult to implement for them. Any object that supports images it would need an option say “Include in Appcache?” and then it would do all the magic when the app starts.

You would need to create a WebPicture object for each Picture in your project. You can then call WebPicture.URL. Remember to store your WebPictures so that they are not garbage collected and the URLs remain valid. Xojo does this for you sometimes under the hood, i.e. when you assign a Picture to an image well.

You would have to do this on a session basis as the pages/controls don’t really exist until there’s a session for them to exist in, and each session has its own set of page instances. In Session.Open you could use PageCount and PageAtIndex to loop through the pages, then for each page ControlCount and ControlAtIndex to loop through the controls.

Darn, didnt realise Xojo creates dynamic images on a session basis. Hmm that would take some work as you would have to have an app cache that is made for each session and of course the concept falls apart because the next time the user comes to the site they will have a new session therefore the URL will have changed and the images stored on the device will not be seen as the same. That completely kills my idea.

In which case Xojo need to add this as part of the framework to be able to get the benefit of appcache (not just on mobiles but any browser that supports HTML5). If you selected to use the appcache then the images would need to be none dynamic which to be honest will enable just general caching to work because at the moment I cannot see how image caching can work at all between sessions which is nuts in a modern internet environment, why force the browser to keep having to download the same image between sessions?

Why not work with images stored on a web space (can be next to your app) and assign them by URL in the IDE at design time instead of dragging them into the project ?
These pictures would stay where they are and would be cached by the browser, would they not ?

[quote=75586:@Michel Bujardet]Why not work with images stored on a web space (can be next to your app) and assign them by URL in the IDE at design time instead of dragging them into the project ?
These pictures would stay where they are and would be cached by the browser, would they not ?[/quote]

This is the best solution if you need persistent image URLs for your cache.

Michel beat me to it. You can include them as part of the package if you’re using Xojo Cloud, then have your code copy them to another folder. Within your project, you’d load them as FolderItems.

[quote=75585:@Nathan Wright]Darn, didnt realise Xojo creates dynamic images on a session basis. Hmm that would take some work as you would have to have an app cache that is made for each session and of course the concept falls apart because the next time the user comes to the site they will have a new session therefore the URL will have changed and the images stored on the device will not be seen as the same. That completely kills my idea.

In which case Xojo need to add this as part of the framework to be able to get the benefit of appcache (not just on mobiles but any browser that supports HTML5). If you selected to use the appcache then the images would need to be none dynamic which to be honest will enable just general caching to work because at the moment I cannot see how image caching can work at all between sessions which is nuts in a modern internet environment, why force the browser to keep having to download the same image between sessions?[/quote]

Set the Session property to Nil.

Nathan, I thought the AppCache was designed for offline applications. To reduce bandwidth and make it more responsive application, the conventional cache system should be enough right?