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',
),
));
}

Comments

wim leers’s picture

Category: bug » support
Priority: Major » Minor
Status: Active » Postponed (maintainer needs more info)

No, 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.

gooms9’s picture

Image Styles work fine with CDN disabled. I stand by my initial assessment of the issue.

wim leers’s picture

1) 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.

wim leers’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closing due to lack of response.

saitanay’s picture

Category: support » bug
Priority: Minor » Normal
Status: Closed (cannot reproduce) » Needs work

Same 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.

wim leers’s picture

Category: bug » support
Status: Needs work » Postponed (maintainer needs more info)

- Drupal 7?
- Far Future expiration?
- Which CDN?

saitanay’s picture

Drupal 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,

saitanay’s picture

Status: Postponed (maintainer needs more info) » Needs work
wim leers’s picture

If 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.

saitanay’s picture

Osing Original Pull mode only..

wim leers’s picture

Title: CDN Module and Image Styles not generating images » CDN Module and Image Styles not generating images when not using a CDN but a subdomain
Component: Module » Documentation
Assigned: Unassigned » wim leers
Category: support » task
Priority: Normal » Minor

You didn't quite understand #9 correctly.

You said:

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.

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.

retrodans’s picture

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.

I 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)?

temkin’s picture

Same 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

billwiens’s picture

We'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.

theoldrupal’s picture

Status: Needs work » Needs review

The issue is valid, encountered this as well. The above code makes sense, can we get this merged in please?

Status: Needs review » Needs work

The last submitted patch, cdn-dont_rewrite_nonexistent_files-1460768-14.patch, failed testing.

wim leers’s picture

Title: CDN Module and Image Styles not generating images when not using a CDN but a subdomain » Image Styles not generating images when not using a CDN but a subdomain (easiest solution: use Far Future expiration)

#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.

david.gil’s picture

Hi 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

wim leers’s picture

#18: the easiest solution is to just enable Far Future expiration. There's almost no valid reason not to enable it.

mlima’s picture

Version: 7.x-2.3 » 7.x-2.5
Component: Documentation » Origin Pull mode

Same issue here.

CDN 7x.25
Origin pull
Drupal 7.21
Akamai

Is far future expiration the fix to this bug then? No patch required?

ropic’s picture

same problem here

mlima’s picture

Turning on Far Future expiration broke my Database. Fortunately I had a backup.

kaidjohnson’s picture

We 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...

stopbox’s picture

It may not be relevant, but putting

$conf['image_allow_insecure_derivatives'] = TRUE; 

in settings.php solved our for NON Far Future CDN problem.

mikeytown2’s picture

Just 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.

wim leers’s picture

Status: Needs work » Closed (works as designed)

All 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:

  • Drupal 7 site in /htdocs/7, with default image styles
  • The Drupal 7 site is accessible via 7.local and cdn-a.local — i.e. cdn-a.local is a "fake CDN".
  • I enabled the CDN module, configured it to use the cdn-a.local domain and kept the Far Future expiration setting *off* (which is the default).
  • I created a node. I uploaded an image, the thumbnail image style rendered in the managed_file element. Upon saving the node, the medium image style rendered.
  • Then I enabled the Far Future expiration setting. I created another node. Uploaded another image. The thumbnail image style rendered. The medium image style rendered.

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:

This will also prevent some issues with CDN's and image style generation as the images will be generated without the request going through the CDN.

There is no problem. It works just fine. Only badly configured setups suffer from this problem.

mikeytown2’s picture

@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