Forums / General Questions / Best way to implement external image server?

Best way to implement external image server?

Locked

Started by qhome on 17 Jan 2007, 12:07 PM · Views: 4,082

Results 1 to 14 of 14
This thread is locked. New replies are disabled.
17 Jan 2007, 12:07 PM
#1
qhome avatar

qhome

Totally Zenned

Join Date:
Feb 2004
Posts:
1,702
Plugin Contributions:
5

Best way to implement external image server?

I know it's a bit of a weird request.. but I have my reasons :)

I'd like to keep all the code and template info on the main server, but have all the product images load from another web server. Can anyone think of an easy way to do this?

My thought was to set up another config setting called:
define('DIR_EXT_IMAGES_SRV', 'http://www.myimageserver.com/');

but that would mean I have to go into all files that call DIR_WS_IMAGES and prefix it to the new config variable.

Any other thoughts?

I also realize that when the store goes into ssl mode I'm going to need a way to put the images in to ssl server mode so that I dont get the IE error. I'll have to think about that one too.

17 Jan 2007, 5:41 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Best way to implement external image server?

... and you're going to have to come up with a creative way to get the IE7 privacy warnings to not show.

Zen Cart does not currently support externally-hosted images. There are a significant number of places in the core code files which would have to be changed to make this happen, and this hasn't been implemented at the present time.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Jan 2007, 7:17 PM
#3
qhome avatar

qhome

Totally Zenned

Join Date:
Feb 2004
Posts:
1,702
Plugin Contributions:
5

Re: Best way to implement external image server?

DrByte:

... and you're going to have to come up with a creative way to get the IE7 privacy warnings to not show.

Zen Cart does not currently support externally-hosted images. There are a significant number of places in the core code files which would have to be changed to make this happen, and this hasn't been implemented at the present time.

well i know that it would take some effort.. i can do it.. i just wondered if there was a better way.

Actually I wonder if i add a database field for the add new product area to have image location and give the option to upload an image like it does now, or enter the url of the image and save that path in the db.

Then I would have to seperate the domain from the image path so I could set it to use the https or http. You mention IE7 privacy? I thought it only asked "Do you want to display both secure and non-secure items?" . If the images are pointed to a secure server.. would they still show that message? .. hmm i guess they might show some similar message since the ssl cert would be from a diff host..

17 Jan 2007, 7:54 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Best way to implement external image server?

DIR_WS_IMAGES is used pretty much universally, for non-template-specific images.
Are you proposing to serve only product-related images externally, or all images, including categories, file-uploads, and more?

Depending on how you intend to do it, it might be easier to simply hook the functions that "display" the image to have them do a replacement of the path with the URL, perhaps after checking whether the local version of the image file exists.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

17 Jan 2007, 8:03 PM
#5
qhome avatar

qhome

Totally Zenned

Join Date:
Feb 2004
Posts:
1,702
Plugin Contributions:
5

Re: Best way to implement external image server?

DrByte:

DIR_WS_IMAGES is used pretty much universally, for non-template-specific images.
Are you proposing to serve only product-related images externally, or all images, including categories, file-uploads, and more?

Depending on how you intend to do it, it might be easier to simply hook the functions that "display" the image to have them do a replacement of the path with the URL, perhaps after checking whether the local version of the image file exists.

Ya. just product images.. your idea sounds like a viable one.

17 Jan 2007, 8:58 PM
#6
qhome avatar

qhome

Totally Zenned

Join Date:
Feb 2004
Posts:
1,702
Plugin Contributions:
5

Re: Best way to implement external image server?

ok so i ran a little test on my main server in ssl mode, and added
<img src="http://imageserver.com/image.jpg" /> to the header. As expected it gave the error about "secure and non-secure" items. But then i changed the code to:
<img src="http**s**://imageserver.com/image.jpg" /> and no error! So it doesnt seem to care that its on another server with a different ssl cert I guess, so long as it is secure. That takes care of my main worries.

18 Jan 2007, 11:36 AM
#7
qhome avatar

qhome

Totally Zenned

Join Date:
Feb 2004
Posts:
1,702
Plugin Contributions:
5

Re: Best way to implement external image server?

Had an idea last night...
Not sure if it will work but it might be easiest.

Currently i just changed the config for DIR_WS_IMAGES from /images/ to the full path of the image server.. and that works fine.

I was thinking, on pages that are SSL, i could re define that constant/variable to add the "s" at the end of http for secure layer.

Could someone explain to me the way the ssl check works and if I should maybe add that to a function or to the top of certain pages like login, checkout, etc... Might be a quick n dirty work around.

18 Jan 2007, 1:01 PM
#8
blainbci avatar

blainbci

New Zenner

Join Date:
Dec 2006
Posts:
27
Plugin Contributions:
0

Re: Best way to implement external image server?

Did you figure out how to use external images? https://www.theoutfitladies.net/cart are all external images....let me know and I will tell you what to do ...its very easy......after someone fixed some codes for me.

Blain

18 Jan 2007, 1:44 PM
#9
qhome avatar

qhome

Totally Zenned

Join Date:
Feb 2004
Posts:
1,702
Plugin Contributions:
5

Re: Best way to implement external image server?

blainbci:

Did you figure out how to use external images? https://www.theoutfitladies.net/cart are all external images....let me know and I will tell you what to do ...its very easy......after someone fixed some codes for me.

Blain

Ya, as I mentioned in the previous post I got non-ssl images working simply by changing the DIR_WS_IMAGES in the configure.php file to the external server. But I noticed you don't use SSL on your site so you probably don't have a way of switching to an SSL version of the image server when on SSL pages?

18 Jan 2007, 5:11 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: Best way to implement external image server?

$request_type is a variable that will be set to 'SSL' or 'NONSSL' depending on the current page configuration. It is set during the init_System load process via init_file_db_names.php

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jan 2007, 7:10 PM
#11
qhome avatar

qhome

Totally Zenned

Join Date:
Feb 2004
Posts:
1,702
Plugin Contributions:
5

Re: Best way to implement external image server?

Thanks Dr. Byte.

And I thought I had it all figured out till I found you can't redefine a constant in PHP .. which technically makes sense.. but I was trying to do:

configure.php:
define('DIR_WS_IMAGES', 'https://www.fonzanoon.com/raretv/images/');

tpl_header.php:
if ($request_type == 'SSL'){
define('DIR_WS_IMAGES', 'https://www.fonzanoon.com/raretv/images/');
}

So I suppose I could use a variable for the image location all the same.. but I dont know that i can leave a variable without $DIR_WS_IMAGES.. which defeats the purpose since I'd have to change all references to DIR_WS_IMAGES

18 Jan 2007, 7:20 PM
#12
qhome avatar

qhome

Totally Zenned

Join Date:
Feb 2004
Posts:
1,702
Plugin Contributions:
5

Re: Best way to implement external image server?

DUH.. i figured it out.

I just comment out the define from the configure.php file and do it at the top of the tpl_header.php file:

if ($request_type == 'SSL'){
  define('DIR_WS_IMAGES', 'https://www.myimageserver.com/images/');
} else {
  define('DIR_WS_IMAGES', 'http://www.myimageserve.com/images/');
}

It works! :) Although it might belong in a better location.. like perhaps in the zen_redirect function that first checks the url.

19 Jan 2007, 3:05 AM
#13
qhome avatar

qhome

Totally Zenned

Join Date:
Feb 2004
Posts:
1,702
Plugin Contributions:
5

Re: Best way to implement external image server?

It's strange. According to the php site, URL support for "getimagesize" was added in PHP 4.0.5. Both my servers are PHP 4.4.2, but when I use the external image server as the image url, the calculate image size doesn't work.

17 Dec 2009, 4:18 PM
#14
micmed avatar

micmed

Zen Follower

Join Date:
Mar 2008
Location:
The Free South
Posts:
165
Plugin Contributions:
0

Re: Best way to implement external image server?

qhome:

It's strange. According to the php site, URL support for "getimagesize" was added in PHP 4.0.5. Both my servers are PHP 4.4.2, but when I use the external image server as the image url, the calculate image size doesn't work.

Hi, did you ever resolve this?

www.theCableStation.com
"If we restrict liberty to attain security we will lose them both."