Hallo
In a multilanguage site where the node path is http://www.mystite.org/en the image path

src="/sites/default/files/myimage.jpg"

is converted to

src=" http://www.mystite.org/ensites/default/files/myimage.jpg"

istead of

src=" http://www.mystite.org/en/sites/default/files/myimage.jpg".

No image is visible

Comments

Xigi’s picture

Version: 6.x-1.0-beta1 » 6.x-1.0

Still an issue for 6.x-1.0

mahnster’s picture

Also have this problem. Subscribbing

mahnster’s picture

And to add on to that, I realized putting a / between "en" (or whatever language) and sites, e.g. /en/sites/all/files/logo.png, does not work because that is not the actual directory...it needs to NOT add the language "directory" onto the URL, it should be just http://www.example.com/sites/all/files/logl.png. Maybe this is the problem with the url() function that this module calls?

ehudash’s picture

I had the same problem in my multi-lingual and multi-domain site.
I fixed it by doing 2 things:
1. for links, keep the original preg_replace call by changing the pattern to look only for href, not src.
2. copy the original preg_replace and paste it under the original (add a nother preg_replace). set it to look only for images (src instead of href) and used the global $_domain variable to set the correct domain base url: $_domain['scheme'].'://'.$_domain['sitename'].'/'

This is the solution I found for multi-domain sites. not sure if it will work on single domain sites as well.

sbozhko’s picture

+1. Subscribed

AlanAtLarge’s picture

Subsicibe too.

planctus’s picture

Well, i had the same problem..
i fixed like this:

  if ( ($op=='proccess' || $op=='prepare') && $text != '') {
    $lang = language_default();
    $text = preg_replace(
      '/(src|href)=(\'|")\//',
      '$1=$2'. url('<front>', array('absolute' => TRUE, 'language' => $lang)),
      $text
    );

    return $text;
  }

The url() function supports languages so we can pass the default one that should not carry any prefix.
I simply needed this for image urls, so i didn't care much about the links.
Obviously this way you're forcing drupal to use the default language even for those ones.
See you,
Da.

lourenzo’s picture

Assigned: Unassigned » lourenzo
Status: Active » Closed (fixed)

Fixed and released in 6.x-1.1

houndbee’s picture

Looks like this change hasn't made it into the 7.x version?