Software Archive
Read-only legacy content
17061 Discussions

no image in html5 app

Jonas_P_
Beginner
544 Views

Hello,

When I test my program in the emulator of the Intel XDK app everything is looking fine.
When I debug or build the app and I'm testing it on my phone: the image from the html code is not displayed.

Code in html:

<article id="me" class="panel">
								<header>
								  <h1>Title1</h1>
								  <p>Title2</p>
								</header>
								<a href="#lichten" class="jumplink pic">
									<span class="arrow icon fa-chevron-right"><span>See my work</span></span>
									<img src="images/me.jpg" alt="" />
								</a>
							</article>

Does anyone know why?

0 Kudos
3 Replies
Chris_P_Intel
Employee
544 Views

Is there any chance that the capitalization of the file varies from the all lowercase you've noted in the src attribute?  Perhaps, the path is "images/me.JPG"  or  "Images/Me.jpg".  or something?  Your Desktop OS might be forgiving, but the mobile phone may not be.

 

0 Kudos
Jonas_P_
Beginner
544 Views

 

Hello thanks for the input. I checked everything and nothing has a capital letter so it looks OK.
I also did the check on my Windows 8 machine. So I build the applicaton, same issue no picture is diplayed.

When I run it on XDK preview app everything is working well.

0 Kudos
Anusha_M_Intel1
Employee
544 Views

Could it be that once the app is built and deployed on your device, it is unable to locate your image file? Are you using an android device? Because the location of your application's root directory will vary depending on the target platform and can also vary with the emulator and the debug containers (e.g., App Preview versus App Analyzer). Here's something you can try to locate files within the project (this code snippet uses a Cordova media object to play a file stored locally in the project but you can modify it to set the location of your image file):

 

// getWebPath() returns the location of index.html
// getWebRoot() returns URI pointing to index.html
function getWebPath() {
    "use strict" ;
    var path = window.location.pathname ;
    path = path.substring( 0, path.lastIndexOf('/') ) ;
    return 'file://' + path ;
}
function getWebRoot() {
    "use strict" ;
    var path = window.location.href ;
    path = path.substring( 0, path.lastIndexOf('/') ) ;
    return path ;
}

var x = window.device && window.device.platform ;
console.log("platform = ", x) ;
if(x.match(/(ios)|(iphone)|(ipod)|(ipad)/ig)) {
    var media = new Media("audio/bark.wav", mediaSuccess, mediaError, mediaStatus) ;
}
else {
    var media = new Media(getWebRoot() + "/audio/bark.wav", mediaSuccess, mediaError, mediaStatus) ;
}
console.log("media.src = ", media.src) ;
media.play() ;

Hope this helps!

0 Kudos
Reply