0

In oscommerce, I have set the DIR_WS_IMAGES from the config.php to be an external url so that the site loads the images from a static cookie-less subdomain.

The images work fine except the pop-us.

The pop-up scritp echo osc_link_object(osc_href_link(DIR_WS_IMAGES. will give the following url http://www.example.com/http://subdomain.example.com/products/originals/image.jpg which will not function as its calling main url plus the DIR_WS_IMAGES url.

How can I amend the script to just call subdomain.excample.com

Thanks for any help.

Regs Fabian

This is the code that is giving a double url [http://www.example.com/http://subdomain.example.com] that needs to be corrected to output just the [http://subdomian.example.com]

<?php 

    $group_id = $osC_Image->getID('originals');

    echo osc_link_object(osc_href_link(DIR_WS_IMAGES.'products/'.$osC_Image->getCode($group_id).'/'.$osC_Product->getImage(),null,'AUTO',false), $osC_Image->show($osC_Product->getImage(), $osC_Product->getTitle(), null, 'product_info'), 'target="_blank" rel=""');?>

Appreciate all the help.

Regs Fab

Fab
  • 278
  • 4
  • 17

3 Answers3

0

Quickest and easiest thing to do (and won't look so out of place in osCommerce's code) is to do a preg_replace().

echo str_replace('/^http:\/\/www\.example\.com\//', '', osc_link_object(osc_href_link(DIR_WS_IMAGES.'whatever.jpg')));

Even better, dig out the global constant from includes/config.php and concatenate it in the regex - be sure to use preg_quote(SITE_BASE, '/') (assuming SITE_BASE is it, can't think of it right now off the top of my head).

alex
  • 479,566
  • 201
  • 878
  • 984
  • Hi Alex, would there be something simpler, which would be echo the subdomain directly without having the script calling the main url and then removing it. – Fab Oct 18 '10 at 13:14
  • @Fabian Borg: Probably, just can't think of one right now (don't have the osCommerce code in front of me). – alex Oct 18 '10 at 13:17
  • Thanks Alex, would appreciate any help ;) – Fab Oct 18 '10 at 13:24
  • HI Alex, had you the time to go through the code... Regs Fab ;) – Fab Oct 19 '10 at 09:13
  • @Fabian Borg Nope, I'm having some time off work and don't want to look at osCommerce code! – alex Oct 20 '10 at 01:01
0

May be this post can help you a bit. http://developerblog.e-cart-solutions.com/2010/10/product-images-images-from-remote-locations/ You can simply restort to replacing the domainname by the sudomain name if the paths are no different using a simple str_replace.

Shiva

shiva
  • 26
  • 2
  • Hi Shiva, thanks for your input, this is the whole code that is calling the double url problem getID('originals'); echo osc_link_object(osc_href_link(DIR_WS_IMAGES.'products/'.$osC_Image->getCode($group_id).'/'.$osC_Product->getImage(),null,'AUTO',false), $osC_Image->show($osC_Product->getImage(), $osC_Product->getTitle(), null, 'product_info'), 'target="_blank" rel=""');?> – Fab Oct 19 '10 at 09:17
  • Hi Shiva, the excersie I have done to move the image folder into a subdomain is not to slow the main site just as your article, since my images are over 1000 pixles wide. Unfortunately I have the double url problem which hopefully your good selves could help me with it. Cheers Fab – Fab Oct 19 '10 at 10:12
  • can you tell me what code you have in the class ? people can help you better if you could show that. – shiva Oct 22 '10 at 03:13
  • Hi Shiva, the whole code is up above in my question. Is there something else that I have to include. Please Guide me. – Fab Oct 22 '10 at 10:27
0

I have managed to correct the problem by simply doing

osc_link_object($link = DIR_WS_IMAGES.('products/'....

instead of

echo osc_link_object(osc_href_link(DIR_WS_IMAGES.'products/'....

Thanks to all does that offered help.

With best regards

Fabian

Fab
  • 278
  • 4
  • 17