Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Does not load images hosted on Amazon S3, Cloudfront and other CDNs #40

Open
avirambm opened this Issue · 13 comments
@avirambm

The library does not load images hosted on external servers, like Cloudfront.

Please advise, thanks.

@caseyohara

@avirambm Yes, this is a technical limitation rather than a bug. The library checks if an image exists with an ajax request, which you can only do on the same domain. See issue #3.

In short, we check if the original image's URL is external and skip it to avoid errors. If you have any ideas for how to handle external (CDN, etc) images, please let me know.

@ghost

Does it load images that are on a subdomain of the domain. Like (images here)images.example.com and (html here)example.com

@gregoirenoyelle

same problem with Amazon S3. I thought that was a caching problem. It will be great if it can with the normal image path find the retina one without using domain.

@nebstrebor

@caseyohara
I just found the retinajs library, so am not familiar with its internals. But its currently not an option for me because we host all our static content on S3.

I was thinking that X-domain is only an issue for Ajax requests but not for image and scripts, so for external images, you could just attempt to load the @2x image via a javascript Image object, using onError and onLoad events on the object to determine whether there was a hit or not. If its a hit (i.e., the load event fires), you could then just set the src on the html img element to that of the Image object you just loaded. Thoughts? I'd be happy to branch and dig into the code if this idea sounds promising.

@ryanburnett

Would love to see external image support - that's the only thing preventing us from using this awesome script.

@cailpearce

To re-ask caseyohara's question, would the script work if we make our CDN serve images from a subdomain?

@mrlundis

The script should work for subdomains if the changes in this pull request are reverted and a proper document.domain value is set.

@mrlundis mrlundis referenced this issue from a commit in mrlundis/retinajs
@mrlundis mrlundis Allow subdomains in image paths, see issue imulus/retinajs#40.
Allows serving retina images from cname:d CDNs and S3 instances. The document.domain and/or CORS also needs to be set up.
470383f
@mrlundis

Has anyone given @nebstrebor's idea a shot?

It seems like a better solution to check for image existence overall, avoiding all the issues with CORS for external sources and in theory reducing the amount of requests to one per image since the check would put the requested image in the browser cache.

@antoinebis

Any news on this? I can't get retinajs to work with my Django/S3 server... and all my requests are done HTTPS as well...

@wkoffel

See Issue #149 for a request to explicitly add support for properly configured CORS domains.

@kieronkeenan

Has there been any resolution on this? Having the same trouble.

@mrlundis

@kieronkeenan There are several solutions available.

I patched the is_external check back in 2012 to accept any subdomain instead of only the current host name, which together with a relaxed document.domain setting (and CORS for S3) solves the problem if you're using a CNAMEd CDN. See mrlundis/retinajs@470383f for details.

Another options seems to be using the data-at2x attribute. See #66 and #124 for details on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.