tags:

views:

29

answers:

3

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

A: 

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
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.
Fabian Borg
@Fabian Borg: Probably, just can't think of one right now (don't have the osCommerce code in front of me).
alex
Thanks Alex, would appreciate any help ;)
Fabian Borg
HI Alex, had you the time to go through the code... Regs Fab ;)
Fabian Borg
@Fabian Borg Nope, I'm having some time off work and don't want to look at osCommerce code!
alex
A: 

Hi

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
Hi Shiva, thanks for your input, this is the whole code that is calling the double url problem <?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=""');?>
Fabian Borg
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
Fabian Borg
can you tell me what code you have in the class ? people can help you better if you could show that.
shiva
Hi Shiva, the whole code is up above in my question. Is there something else that I have to include. Please Guide me.
Fabian Borg