In Drupal 7, one should use file_create_url() to create a URL to link to a file. This single function should be used to generate all file URLs, so that all file URLs can be altered to use a CDN instead (or your own static file servers, or whatever you'd like).

However, the CDN module already supports file_create_url() in the form of a Drupal 6 core patch. Just today, somebody created an issue, asking (explaining incorrectly) how to make Fusion themes compatible with the CDN module (i.e. how to make it use file_create_url()). Well then, I thought, why not roll a patch so that any Fusion-based theme automatically does the right thing and would therefore automatically be compatible with CDN integration?

The added advantage is that you just have to delete a couple of lines of code and it will be compatible with Drupal 7 right away!

So, attached is the patch that does just that. It automatically detects whether file_create_url() is available and falls back to the "Old Drupal 7 Way" if it's not available. The patch has not been tested, but the code should be right.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

I forgot: the issue I'm referring to that requests this functionality is #969576: Here's how to make Fusion based themes css go to the CDN.

Wim Leers’s picture

Issue tags: +WPO
Wim Leers’s picture

Rerolled. I don't know what I was thinking. Stupid bug fixed.

Wim Leers’s picture

No feedback whatsoever? I thought Fusion theme development was very active?

stephthegeek’s picture

Assigned: Wim Leers » sociotech

Hey Wim, thanks and it is.. we got a new Fusion release just out as you were working on this so we didn't have time to look at it during the that release process, but will try to take a look soon. Obviously this will need some extensive review and testing. Sorry for the lack of response!

coltrane’s picture

Status: Needs review » Needs work

This is going to need re-roll if #864668: Local and IE Fixes CSS may not be flushed from cache gets in or vice versa.

#3 no longer applies.

coltrane’s picture

Status: Needs work » Needs review
FileSize
4.9 KB

And updated patch. I tested without CDN and stylesheets work fine. You could wait for a CDN tester but otherwise this looks ready to go.

Wim Leers’s picture

Thanks for the reroll! Looks good to go :)

stephthegeek’s picture

Assigned: sociotech » aquariumtap
essenceofginger’s picture

Is this now working in fusion core? Seems all images being served up by the fusion-based theme i'm running aren't being delivered through CDN. Baffled as to whether I need to patch or not.

I'm running Drupal 7.

Status: Needs review » Needs work

The last submitted patch, Fusion-support-CDN-969824-7.patch, failed testing.

Wim Leers’s picture

Hasn't been committed AFAICT.

aquariumtap’s picture

Assigned: aquariumtap » Unassigned
Poieo’s picture

Version: 6.x-1.x-dev » 7.x-2.x-dev
Issue summary: View changes

If we can get a re-roll against the current dev and some testing done I would be glad to commit this.