Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Url form to reference local images on remote web pages

I am tryng to figure this out. I have an image in my resources folder. Let's call it /images/my.jpg

I have a remote page on my webserver I am opening in a webview. What url can I use to get the local image?

— asked March 25th 2010 by Laney Dale
  • iphone
  • webview
0 Comments

4 Answers

  • You can try using a relative URL to the JS scripts' location. For example if the JS script is in /Resources/windows/viewwindow and the image is in /Resources/images then your URL should be "../images/<image file name>".

    Or you can code it relative to the Resources directory - ie from image_view_file.js in the kitchen sink…

    var win = Titanium.UI.currentWindow;
    
    var f = Ti.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory,'images/appcelerator_small.png');
    
    — answered March 25th 2010 by Gregor Munro
    permalink
    0 Comments
  • I do not think I am explaining myself, or I do not understand. in the remote page at www.mysite.com/mypage.html. how can I pull images form my app? ie replace the <img src="/images/frontbox.png" />

    — answered March 25th 2010 by Laney Dale
    permalink
    0 Comments
  • Ooooh that way round… Umm, thats going to be a challenge. You may be able to do something with a fireEvent, tho its really a chicken and egg thing.

    — answered March 25th 2010 by Gregor Munro
    permalink
    0 Comments
  • Hi there Laney,

    I'd be very surprised if a remote web page was able to access files on a the device. you might have to write a service on the server and use a 'put' call from Titanium to send them.

    Alternatively you could 'mash-up' a webView and an imageView in the same window, but the image would only be seen on your device.

    cheers,
    Chris.

    Nice seasonal reference there Gregor!

    — answered April 2nd 2010 by Chris Reed
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.