Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The Insert module should not insert CDN URLs, because that prevents users from switching from one CDN to another.
Not sure yet how we're supposed to solve this, but it definitely needs to be solved. The Insert module should always insert either root-relative or protocol-relative, non-CDN URLs.
Comment | File | Size | Author |
---|---|---|---|
#8 | 1863530-8.patch | 843 bytes | Wim Leers |
Comments
Comment #1
kmontyThanks for taking on this issue, Wim!
I think one of the more obvious (but potentially less-sexy) solutions is to use an input filter when inserting an image. If there was something like
[img:/sites/default/files/imagecache/preset/image.jpg,alt=this is alt text\, escape all commas yada yada]
inserted into the node body, the CDN module could process that and ensure the image URL was always correct. Potentially, there could even be a hook_uninstall to manually recreate HTML img tags if the CDN module was not enabled.The drawback here is that the image wouldn't appear in WSYIWYG editors (unless we wrote a plugin for each editor).
Comment #2
Wim LeersThat wouldn't solve the problem.
The root cause for the problem is that we have no contextual information in
file_create_url()
, and thus also not inhook_file_url_alter()
. i.e. the purpose of the insert module is different from the typical purpose: instead of serving production traffic, you're generating "canonical content". (I hope that makes sense, I can't think of a better explanation right now.)So, the question is: how can we know that we're generating "canonical content" (or even simpler by being narrower: how can we know the Insert module is calling
file_create_url()
)?Comment #3
iamEAP CreditAttribution: iamEAP commentedExtremely dirty, but you could call debug_backtrace() to find the caller of file_create_url(). I believe the Memcache module uses this trick to get around some limitations of Core.
Comment #4
ttkaminski CreditAttribution: ttkaminski commentedA workaround for this insert issue is to include an exception for authenticated users. In the blacklist, add:
node/*/edit
Or you can add the patch to the insert.module. See: #2001284: Absolute urls inserted with CDN module enabled
Comment #5
Vacilando CreditAttribution: Vacilando commentedJust also been bitten by this nasty problem... as usual, in hurry, switching off the CDN module quickly solved the problem. But I would love to see a solution so that I can use the module again.
EDIT: Tried entering */edit under Exceptions -> "DRUPAL PATH FOR AUTHENTICATED USERS" in CDN config screen but that did not help.
Comment #6
plopescHello
Looks like I fixed this bug in my project adding both
node/*/edit
andfile/ajax/*
URLs to the blacklistDRUPAL PATH FOR AUTHENTICATED USERS
Now, when uploading images, hook_file_url_alter() does not rewrite the URL and everything works fine for me.
Regards
Comment #7
Wim LeersHrm, that makes total sense. In fact, I think just
file/ajax/*
would do the trick. It's still a hack, but it's a reasonable one.Will test that some more before committing, just to make sure.
Comment #8
Wim LeersConfirmed to be working.
Comment #10
Wim Leers