Unable to render google drive image file

https://pokemon-empire-pbs.infinityfreeapp.com/Test/?i=2

Picture not rendering on site

Hi,

Firstly some context,

Im using a free sub domain from infinityfree and one of the limitations of that is the daily hit rate (can’t exceed 50,000)
Because of this I’m unable to upload images (there’s around 1000 small files) of pokemon sprites as that massively contributes to the daily hit rate.

So I’m trying a workaround which is to upload the files onto google drive and read the files from there via it’s individual file url.
From looking at the console it appears it’s reading the g-drive file correctly but the image still isn’t loading. The folder in which the file is located is set to “anyone with the link can view” so there shouldn’t be accessing issues here

What am I missing here?

Ask google drive?

Google Drive, as far as I know, doesn’t support direct file embeds, and probably have hotlink protection. You must use services that allow embeding directly.

3 Likes

I thought it only doesn’t support private file embeds?
The folder that contains the file has been shared publicly, so it should still work

Sorry, I did some digging and figured out that it was indeed possible to embed Google Drive files.

I don’t know what is exactly wrong, you may wanted to do some deeper searching, or use services that just allow direct file embeding.

2 Likes

I’m not sure if this applies here, maybe an admin would be able to confirm if the above screenshot has some relevance to my issue.

I also tried onedrive and the same thing occured. It might be a restriction from the hosting service

I think that our hosting have CORS policies that block other sites from embeding your content, but it shouldn’t affect you from embeding files from other sites if they have correct CORS policies set.

Google is blocked in my country so unfortunately I cannot test the Google side — tests here showed no errors embeding other sites’ files.

See this?

image

Over 3000 request just for one page view.
Wow, that’s a lot.

For image that was loaded

This is what I see

image

For those that failed to load

So make sure you links are correct and valid

3 Likes

Update:

I see this now even for those links that are valid

I suspect google drive and imgur have some kind of limits in place as well.
3000 over request in one page view is abusing their services as well

4 Likes

The imgur file was solely to test if using the embed imgur link worked and it did. I only tested just with bulbasaur but because the other pokemon was still mapped to the google drive file ids, that’s why the number of requests occurred

This is the call to that file

All I want to achieve is show the sprite of each pokemon. Each pokemon has an internal id of 001 for bulbasaur and 002 for ivysaur etc etc.
I’m unable to upload images directly to the site without maxing out the daily limit rate (there’s over 1000 sprites).

As a workaround, I’m doing a mapping mechanism where I upload the sprite (that is named 001.png etc) to google drive and map that with the pokemon id of 001.
Google drive doesn’t explicitly show the filename in the url, it’s a file id value instead. So that’s why I’m mapping the pokemon id to the file id.
I just don’t know why the image doesn’t render despite me successfully achieving the above and the console confirming that it’s displ\ying the correct url.

Atm I’m trying to use Imgur’s API to bulk upload onto imgur and then map to a json file. But that’s proving really difficult

You probably have a lot of images in your browser cache, so you don’t see the actual number of REQs

Basically your website overwhelms imgur server with a flood of traffic (DOS) and the server defends itself and refuses to serve as soon as the number of requests exceeds a certain number

4 Likes

Well, you can break that single page into several pages.
You may want to consider lazy-loading as well

Likely due to this

2 Likes

it would be ideal if you put all the Pokemon images in one image (image sprites)

so then you would only have one request instead of a thousand
but I assume that then it also requires JS modification and mapping of each image coordinate where which image is positioned in that one image (file) and connect it all.

and then tell JS or through CSS to display only a specific rectangle (image of a Pokemon like coordinate > silly example 0,0 - 50,50)

3 Likes

This was my ideal route, but I found it difficult to map the pokemon id to specific coordinates. in the sprite sheet. Which is more of a knowledge gap than anything.
Internally, each pokemon has an id of 001, 002 and so forth. Each sprite is named 001.png so the id and sprite name matches like for like.
I’m not sure to get that filename metadata from the sprite sheet.

image
As a test with g-drive, I now have one id mapped to a single image google file id. And still it doesn’t render

Looking at the logs, it says:

Which is odd because I’ve set the sharing permission of the g-drive file to anyone with the link can view

maybe someone has already done it - if not then manually

I don’t have time to study your JS code, but it probably needs some redesign of its way of working

Give us the URL for the test page that calls gdrive instead of the one from imgur that we know

3 Likes

Something went weird with my message before so im not sure if it posted correctly:

The test url is https://pokemon-empire-pbs.infinityfreeapp.com/Test/
Elements might be cached which is probably why it was still showing imgur last time

instead of this

src="https://drive.google.com/uc?export=view&id=1_xkjgmMR-DLq69AZoaJ7-0Py5_vVQkKu"

Use this

https://lh3.googleusercontent.com/d/ plus FILE ID

example
src="https://lh3.googleusercontent.com/d/1_xkjgmMR-DLq69AZoaJ7-0Py5_vVQkKu"


but in any case, I think that after a large number of REQs, Google will simply block you

4 Likes

That worked! Thanks so much!

Tested first with bulbasaur. After including all the mappings it’s done over 1000 requests, as expected since there’s over 1000 google file ids

I’ll monitor the daily hit rate and see what happens

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.