Software Archive
Read-only legacy content
17061 Discussions

adding an image

Shawn_A_
Beginner
366 Views

I'm working on an app that has a "login" button.

When the user types in their credentials and clicks "log in" I display an animated GIF (spinning wheel).

That only works when I include a full path to the file in the code, i.e; c:\apps\xdk\images\file.gif

This does not get included in the test "push" and I'm guessing also not in a build.

My question: How do I add a picture to my app that will get included in both the test and the build?

thanks

 

0 Kudos
3 Replies
Amrita_C_Intel
Employee
366 Views

Have you tried using adding this way?

563431(1).PNG

563431(2).PNG

So if you see the media on the left side. You can select image and provide the path.

0 Kudos
Anusha_M_Intel1
Employee
366 Views

Hi Shawn,

I would say, use a relative path. From where you are accessing the image: 

../images/login.png will move you back one folder.

../../images/login.png will move you back two folders.

/images/login.png will take you back to the root folder no matter where you are.

 

To open the image in a new window, use the InAppBrowser plugin. This will be a simple event handler in your 'js/app.js':

function localImg() {
        var ref = window.open('images/login.jpg', '_blank', 'location=yes');

}

Bind this to your login button and see how it works. You should include the inappbrowser plugin from Project tab -> Plugin. Just tick the plugin from the Standard Cordova plugins list. 

 

0 Kudos
Shawn_A_
Beginner
366 Views

I got it figure out.
I was looking in the wrong folder!!!

d'oh!

thanks for your help

0 Kudos
Reply