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.
Comment | File | Size | Author |
---|---|---|---|
#7 | Fusion-support-CDN-969824-7.patch | 4.9 KB | coltrane |
#3 | fusion-file_create_url-cdn-support-3.patch | 4.71 KB | Wim Leers |
fusion-file_create_url-cdn-support.patch | 4.73 KB | Wim Leers |
Comments
Comment #1
Wim LeersI 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.
Comment #2
Wim LeersComment #3
Wim LeersRerolled. I don't know what I was thinking. Stupid bug fixed.
Comment #4
Wim LeersNo feedback whatsoever? I thought Fusion theme development was very active?
Comment #5
stephthegeek CreditAttribution: stephthegeek commentedHey 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!
Comment #6
coltraneThis 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.
Comment #7
coltraneAnd updated patch. I tested without CDN and stylesheets work fine. You could wait for a CDN tester but otherwise this looks ready to go.
Comment #8
Wim LeersThanks for the reroll! Looks good to go :)
Comment #9
stephthegeek CreditAttribution: stephthegeek commentedComment #10
essenceofginger CreditAttribution: essenceofginger commentedIs 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.
Comment #12
Wim LeersHasn't been committed AFAICT.
Comment #13
aquariumtap CreditAttribution: aquariumtap commentedComment #14
Poieo CreditAttribution: Poieo commentedIf we can get a re-roll against the current dev and some testing done I would be glad to commit this.