Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Html5 images not showing

A topic by sadpress created Aug 15, 2022 Views: 1,251 Replies: 5
Viewing posts 1 to 4

I have a html file called index.html, and a folder called Images. They're zipped and uploaded, but the images don't display.

https://sadpress.itch.io/shrike-deck

It works fine when I test it locally, but not  when it's uploaded to Itch.

Any ideas?

The zip is only 13MB, and there are only about fifty images in the Images folder.

Thank you!!

(+1)

More info, in case it's helpful:

If I copy the image address I get something like "v6p9d9t4.ssl.hwcdn.net/html/6337620/Images/Slide15.jpg" and when I try to access it directly, I get this message:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<Error>

<Code>AccessDenied</Code>

<Message>Access denied.</Message>

<Details>Anonymous caller does not have storage.objects.get access to the Google Cloud Storage object.</Details>

</Error>

Thank you!

Admin

Please check the HTML troubleshooting guide here https://itch.io/docs/creators/html5#common-pitfalls

The answer to your issue is likely there.

(+1)

Thanks! - I have been through the list and I don't think it's any of those?

I just tried starting from scratch, creating a JS file in a text editor, but I'm still having the same issue. It works locally but not when I upload it.

I've also temporarily set it to download the zip file instead, so at least it's not showing the broken link.

The contents of index.html is this (except with 55 images, not just 6):

<html>

<head>

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin

var theImages = new Array() 

theImages[0] = 'Slide1.jpg'

theImages[1] = 'Slide2.jpg'

theImages[2] = 'Slide3.jpg'

theImages[3] = 'Slide4.jpg'

theImages[4] = 'Slide5.jpg'

theImages[5] = 'Slide6.jpg'

var j = 0

var p = theImages.length;

var preBuffer = new Array()

for (i = 0; i < p; i++){

   preBuffer[i] = new Image()

   preBuffer[i].src = theImages[i]

}

var whichImage = Math.round(Math.random()*(p-1));

function showImage(){

document.write('<img src="'+theImages[whichImage]+'" width="540" height="720">');

}

//  End -->

</script>

</head>

<body>

<input type="button" value="Draw Again" onClick="window.location.reload(true)">

<br/>

<script language="JavaScript">

<!-- Begin

showImage();

//  End -->

</script>

</body>

</html>

Admin

I’m sorry but we can’t troubleshoot your code, that’s your responsibility! The issue is likely because you are using incorrect case when trying to load the file, as described in the troubleshooting guide I linked. Please ensure you match the upper/lower case of all letters when referencing a file.

If you have found a solution to your problem then I also recommend posting that here so others who may have a similar issue can be helped in the finding a solution.

(+1)

It was just the letter case - I had ".jpg" but the files had all been exported as ".JPG". 

(Somebody on another a forum helped me out - they pointed out that if it was working on my computer but not on any host (I tried Itch and another one), then it was very likely a case thing, since Windows typically isn't case sensitive.  That's when I noticed I didn't have my file extensions switched on!)

Thanks for your help!

This topic has been auto-archived and can no longer be posted in because there haven't been any posts in a while.