I use Parallel module to alter images URL and use cookieless domain for them.
Here is an example of ColorBox gallery image :
<a href="http://www.example.com/sites/default/files/imagecache/lightbox2/field_photo/dir1/0387.jpg" title="www.example.com" class="colorbox imagefield imagefield-imagelink imagefield-field_photo" rel="gallery-all">
<img src="http://cdn3.example.com/sites/default/files/imagecache/teaser/field_photo/dir1/0387.jpg" alt="www.example.com" title="www.example.com" class="imagecache imagecache-teaser" width="160" height="107" />
</a>
As you can see gallery image use CDN domain but ColorBox popup image doesn't.
Here is how to solve it.
In colorbox.theme.inc line 98 replace
$link_path = imagecache_create_url($presetname, $path);
by
$link_path = cdn_url(imagecache_create_path($presetname, $path));
using this new function
function cdn_url($_url) {
if (variable_get('parallel_enabled', TRUE) && variable_get('parallel_domain_img', '') != '') {
$base_url = variable_get('parallel_domain_img', $base_url);
return $base_url.'/'.$_url;
}
else {
return url($_url);
}
}
Maybe this new function I propose will be include in Parallel module in future.
See #749448: Lightbox compatibility : replace href tags
Comments
Comment #1
frjo commentedParallel module must have the same issue with every module using imagecache_create_url(). To implement a custom solution in every module for this is not the way to go.
And if I understand the Parallel module correctly there are really no reason to rewrite Colorbox/Lightbox paths. What would the benefit be?
Comment #2
srobert72 commentedYou can configure Drupal site on : www.example.com
And alter all images URL to : www.cdn-example.com
Main Drupal site uses HttpSession and then cookies infos in all HttpRequest headers.
CDN site doesn't so all requests are really lighter.
It's better for performance and SEO.
I agree with you it's not a good approche to update all modules.
Better solution would be common one.
But is it possible without patching Drupal core ?
Can we overwrite imagecache_create_url() function in Parallel module ?
Imagecache module doesn't use file_create_url, it rewrites it.
So I think solution would be to overwrite imagecache_create_url() function by Parallel module.
Comment #3
frjo commented