One example with Lightbox but could be reproduced for others tools.

We use 2 pictures : small one and big one which will be visible thanks to Lightbox.

Small one uses Only local images are allowed. tag.
==> this one is correctly replaced by Parallel module

Big one uses tag.
==> this one is not replaced by Parallel module

To solve it I think we must edit parallel_image_replace() function to make its pattern looks for "src" and "href" tags. But how to recognize in href URL there is really an image ?

CommentFileSizeAuthor
#2 file.patch924 bytesball.in.th

Comments

srobert72’s picture

Other solution could be to give us function with2 parameters : URL and type (img, js, css).
Someting like parallel_replace_url($url, $type)

Then we use it to replace our URLs before to write them in our templates when we know its an image.

This solution isn't as nice and global. But it's a simple one.

ball.in.th’s picture

StatusFileSize
new924 bytes

I was just trying to get parallel to work with lightbox images. Perhaps patching the core file_create_url() could be used for this.

srobert72’s picture

I think this patch will not perfectly work.
It replace all URL from /files directory with Parallel IMG alias even if that's not an image.

srobert72’s picture

In my theme file : template.php
I created this 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);
  }
}

And I use it this way :

$mypicture_lightbox = cdn_url(imagecache_create_path('lightbox2', $mypicture['filepath']), array('absolute' => TRUE));

cdn_url($url) is used same way as url($url) : http://drupalcontrib.org/api/function/url/6

I use cdn_url($url) in my template when I construct Lightbox tag manually. It works.

But it doesn't resolves problem when Lightbox tag is constructed by Views for example.

EDIT:
Sorry Parallel module works for automatic Lightbox tags in Views with Lightbox rendering image.
So my problem was just for Lightbox tags generated manually in template.php.
In this case using cdn_url($url) solves my problem.

mikeytown2’s picture

Replacing lightbox images is sorta overkill, unless your using this as a true CDN. Thought on how to tackle this?

@srobert72
You have an interesting idea, I should include your function; but have it take 2 parameters: $url, $domain. $domain can be img, css, js.

srobert72’s picture

Similar problem with ColorBox module.
See #773006: Add support for the Parallel module

Andrew Udvare’s picture

Meh, I strongly suggest some drupal_alter()'s in these replacement functions for fixes so we don't have to hack 'core' (parallel.module) so to speak.

wim leers’s picture

Status: Active » Closed (fixed)