Hey, we've been having a problem using this module in drupal 7.10 with image styles. The problem is that if the image style is not generated, then it never gets generated because the URL is 'CDNized'. I've gone into the CDN module and at this point in the code... I added the return statement right after if(!file_exists($uri)) and it seems to work because if the image isn't generated, then it just uses the default image URL. It appears to me that is what is actually supposedly happening in this line anyways though, so I'm kind of confused why it works with the return statement there, and not without.
Any thoughts would be appreciated.
// If the file does not yet exist, perform a normal HTTP request to this
// file, to generate it. (E.g. when ImageCache is used, this will
// generate the derivative file.)
if (!file_exists($uri)) {
return;
drupal_http_request(
url($uri, array('absolute' => TRUE)),
array(
'headers' => array(
// Make sure we hit the server and do not end up with a stale
// cached version.
'Cache-Control' => 'no-cache',
'Pragma' => 'no-cache',
),
));
}
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | cdn-dont_rewrite_nonexistent_files-1460768-14.patch | 404 bytes | billwiens |
Comments
Comment #1
wim leersNo, that's why the
drupal_http_request()call is there: this should generate the image. That's exactly why it *can* be generated in the first place.I suspect that Image Styles won't work even if you disable the CDN module. Please give that a try.
Finally, it's extremely rude to bump your issue to "major" and to mark it as a bug report if you're not 100% certain this is the case. Don't assume the module is broken if thousands of people use it, but assume you're doing something wrong.
Comment #2
gooms9 commentedImage Styles work fine with CDN disabled. I stand by my initial assessment of the issue.
Comment #3
wim leers1) Did you upgrade to version 2.4?
2) Your assessment is definitely wrong. The original (non-CDN) URL should *not* be served, otherwise there's no point in using the CDN module.
Comment #4
wim leersClosing due to lack of response.
Comment #5
saitanay commentedSame issue .
With CDN disabled, imagestyles work fine and the various images in sites/default/files/styles are created
When CDN is enabled, when i attach a pic to the node, the images with required styles are not created and hence the views show broken image urls,.
1) Yes using 2.5
2) The CDN image url is only being served, but the image was never created,
Currently as a work-around, we are turning off CDN module while creating new nodes or while adding pics to nodes.
Comment #6
wim leers- Drupal 7?
- Far Future expiration?
- Which CDN?
Comment #7
saitanay commentedDrupal 7, v2.5
Origin Pull
CDN mapping
http://img1.mydomain.com http://img2.mydomain.com http://img3.mydomain.com|.css .jpg .jpeg .png .gif
(Not any real CDN. just a subdomain to allow multiple connections on the image heavy website. Each page loads around 200 images from the same domain)
Far Future expiration disabled.
CDN supports HTTPS disabled,
Comment #8
saitanay commentedComment #9
wim leersIf you're not using an Origin Pull CDN and want image styles to be generated, you might need to set up your "CDN domain" as another site in Drupals multisite functionality.
Comment #10
saitanay commentedOsing Original Pull mode only..
Comment #11
wim leersYou didn't quite understand #9 correctly.
You said:
The consequence of this is that image styles won't be generated properly, unless you make your CDN domain into a proper multisite as well.
Assigning to myself to document this, but your support request has been answered.
Comment #12
retrodans commentedI think I am having similar issues with our site (not loading image styles when accessed through cdn path), what do you exactly mean in terms of the setup of this multidomain. Can I just set it up to use everything from the original one (DB and all)?
Comment #13
temkin commentedSame issue on my site. Here are the details:
Drupal - 7.18
CDN - 7.x-2.5
Origin Pull mode (without Far Future expiration)
Amazon CloudFront
Thumbnails are not being generated correctly. Is there anything else I can do to help you tackle that issue?
Thanks in advance!
- Artem
Comment #14
billwiens commentedWe've had the same issue. We've got multiple sites sharing the same CDN origin, and image styles that haven't been generating are 404'ing, since our CDN origin doesn't necessarily have the same Drupal styles configuration.
I've fixed this by including a call to file_exists inside cdn_check_file function. If the file doesn't exist, it doesn't rewrite the URL, and the image style is generated normally. I've verified that this fixes our issue with image styles not being generated, and I've attached a patch with our changes.
Comment #15
theoldrupal commentedThe issue is valid, encountered this as well. The above code makes sense, can we get this merged in please?
Comment #17
wim leers#14 is not a valid solution. It causes non-CDN'd file URLs to end up in cached pages, thus reducing the usefulness of CDNs.
An easier solution is to just use CDN module's Far Future expiration, then non-existing-but-to-be-generated files will be generated automatically.
Comment #18
david.gil commentedHi Wim,
i am trying to configure CDN module to implement a fake CDN for use cookieless domains for js css and images and i am having troubles with images generated with styles and i cannot figure how must i config multi-site to do what you say as solution in #11.
Any hint? Best
David
Comment #19
wim leers#18: the easiest solution is to just enable Far Future expiration. There's almost no valid reason not to enable it.
Comment #20
mlima commentedSame issue here.
CDN 7x.25
Origin pull
Drupal 7.21
Akamai
Is far future expiration the fix to this bug then? No patch required?
Comment #21
ropic commentedsame problem here
Comment #22
mlima commentedTurning on Far Future expiration broke my Database. Fortunately I had a backup.
Comment #23
kaidjohnson commentedWe have run into a few scenarios where new images aren't being loaded. We are not currently using Far Future expiration due to it resulting in some other images/files breaking.
Using the Insert module for injecting images into our content, images are being saved in the database with the CDN path rather than the relative path. The patch from #14 does resolve this issue, however I understand there are other caching issues at stake here.
We also have content generated by various data importers, many of which import images to the site, and those new images are not being properly found/served/generated with the CDN. We expect the patch above to work, but again, we understand the implications of caching those images locally.
Looking further into the CDN module, I see where _cdn_basic_farfuture_generate_file($uri) is being called within a Far Future enabled wrapper. My primary question is why do you only check is the file_exists and _cdn_basic_farfuture_generate_file when Far Future is enabled? It seems to me that this approach in place of patch #14 would be a good alternative, regardless of the Far Future status.
Any insights would be appreciated...
Comment #24
stopbox commentedIt may not be relevant, but putting
in settings.php solved our for NON Far Future CDN problem.
Comment #25
mikeytown2 commentedJust released a 7.x module that will generate image styles on file upload
https://drupal.org/project/imageinfo_cache
Should help to mitigate some of the issues reported in here.
Comment #26
wim leersAll those who can't get this to work, use mikeytown2's imageinfo_cache module — which is what Drupal core should be doing in the first place :)
Finally, I spent a LOT of time today on reproducing this issue, but I can't. My setup:
/htdocs/7, with default image styles7.localandcdn-a.local— i.e.cdn-a.localis a "fake CDN".cdn-a.localdomain and kept the Far Future expiration setting *off* (which is the default).IOW: I can't reproduce any of this. Until somebody can come up with very clear, very explicit steps to reproduce, I won't work on this. Please open a new issue if you encounter this again.
@mikeytown2: you have a false statement on the project page though:
There is no problem. It works just fine. Only badly configured setups suffer from this problem.
Comment #27
mikeytown2 commented@Wim Leers
Thanks, made changes to the project page. Let me know if the wording is still unacceptable :)
https://drupal.org/node/1025130/revisions/view/2803389/2817775