Zen Cart Logo
Forums / General Questions / Using external images

Using external images

Views: 3,331

Results 1 to 14 of 14
26 Dec 2012, 3:46 AM
#1
iainmcg avatar

iainmcg

New Zenner

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

Using external images

Hi guys,

hope you can assist me as this hs been a nightmare. My supplier wants me to use live images from their site for my products. I've installed the external image mod but the zen cart is looking for my images in the location:

http://thepetpad.co.uk/images/thepetpad.co.uk/images/round%20pink%20paw.JPG

instead of
http://thepetpad.co.uk/images/round%20pink%20paw.JPG

Can anyone tell me what's wrong. The site is https://www.thepetpad.co.uk.

Thanks guys

Iain

26 Dec 2012, 1:53 PM
#2
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Using external images

IAINMCG:

I've installed the external image mod ...

Well... it is not so much an "installation" as a series of core edits. And the "module" was last tested on ZC 1.3.8 - so whether it is compatible with 1.5 is questionable.

HOW did you do these edits? Did you backup the original core files mentioned in the instructions?

Are you putting the full URL path into the image field?

This is not a recommended way of handling images in your website. Ask your "supplier" to either make available their image repository (where you can download the images to your server), or put them onto a CD for you.

Your supplier needs to be told that modern CMS platforms don't handle things this way anymore.

26 Dec 2012, 5:47 PM
#3
iainmcg avatar

iainmcg

New Zenner

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

Re: Using external images

Hi,

I did backup all my files before doing the core edits, I used the plugin external image tool for zen cart and followed instructions.

I could probably download all the images but won't this slow my sight down and take longer to load?

Thanks

26 Dec 2012, 6:11 PM
#4
limitless avatar

limitless

Inactive

Join Date:
Jan 2012
Posts:
496
Plugin Contributions:
0

Re: Using external images

IAINMCG:

Hi,

I did backup all my files before doing the core edits, I used the plugin external image tool for zen cart and followed instructions.

I could probably download all the images but won't this slow my sight down and take longer to load?

Thanks

It will actually be faster, as you won't be dependent on yet another web server serving up the images.

The only time it may help would be if you use a CDN type network, cloudfront, cloudflare, akamai, etc but you would still want to host the images.

26 Dec 2012, 7:22 PM
#5
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Using external images

Limitless:

It will actually be faster, as you won't be dependent on yet another web server serving up the images.

The only time it may help would be if you use a CDN type network, cloudfront, cloudflare, akamai, etc but you would still want to host the images.

The "path-to-image" is nothing more than a REFERENCE in the database, RELATIVE to the CORE PATH defined for a resource's LOCATION.

For "external" images, what you are having to do is OVER-RIDE core behaviour, with CUSTOM behaviour.

CORE behaviour assumes that product images are going to reside in the images folder (or possibly a SUB-folder in the images folder).

The PATH to this folder is established in the configure.php file, and CORE behaviour states that it is whatever-folder-name in the DIR_WS_IMAGES define statement.

Now... once you have made all the edits to the CORE FILES that use "DIR_WS_IMAGES" as the key referencing point for INTERNAL images, you are going to have to MANUALLY ADD the URL to the path for every product image you add.

So... what you need to do is this.

When you ADD a product in your admin console (admin>>>catalog>categories/products>>> add a product), when you get to the part which asks you to add an image, you need to TYPE INTO the field that says:-
Or, select an existing image file from server, filename:
domain.com/images/image1.jpg

WHERE:
domain.com (is the domain of your supplier... do not enter "http://")
/images (is the DIRECTORY on their server where the images live)
/image1.jpg (is the name of the image for the product in question)

27 Dec 2012, 12:13 AM
#6
iainmcg avatar

iainmcg

New Zenner

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

Re: Using external images

Hi schoolboy, tried that but image still tries to et image from location mydomain.com/images/domains want.com/images/image1.jpg

Can u help, I'm so frustrated lol

27 Dec 2012, 9:44 AM
#7
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Using external images

IAINMCG:

Hi schoolboy, tried that but image still tries to et image from location mydomain.com/images/domains want.com/images/image1.jpg

Can u help, I'm so frustrated lol

If you try to link to external images you will spend MONTHS manually entering the URL for each product. It looks like you have not successfully made the required edits to all the PHP files either... and as I said, that "module" was designed for ZC 1.3.8. If you are using a later version of ZC, there is a possibility that it needs further attention.

You have two options...

  1. Pursue the external images "solution" by making sure your PHP contains ALL the edits indicated in the module.
  2. revert to CORE behaviour, and ask your supplier to provide you with the product images.

I have built three pet products websites in the last 2 years - one of which uses a drop-shipper, and this drop shipper provides all the images. They are made available as a download (zip) file, so my client just has to go fetch the zip.

If your supplier provides a SPREADSHEET containing the URL's to the images, then you might be able to "scrape" them using a utility like W-Get. You create a TXT file from the column showing the URL's to the images, and W-Get runs each line in turn, collecting and saving each image to your hard drive.

I have successfully used W-Get to scrape several thousand images off a supplier's site. Takes an hour or two, but you can just let it run in the background.

28 Dec 2012, 2:12 PM
#8
iainmcg avatar

iainmcg

New Zenner

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

Re: Using external images

Thanks for that, think I'll try wget. Have an issue thought that I have an individual URL for every image ie domain.com/img/1.jpg, domain.com/img/2.jpg

So how would I create the txt file and what command woul I use In wget to download them all.

Thanks again

28 Dec 2012, 3:09 PM
#9
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Using external images

I believe you would just put each URL on a separate line in your txt file. Schoolboy will have to advise you on how to use W-get... or you could go get it and read its instructions.

28 Dec 2012, 4:00 PM
#10
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Using external images

Your supplier's spreadsheet is likely to have a column that lists the paths to the images - something like:

http://www.supplier.com/images/1234567.jpg
http://www.supplier.com/images/2345678.jpg
http://www.supplier.com/images/3456789.jpg

Copy this column and paste it into a plain text editor (notepad++), then save it as a .txt file .

Save this file in the root (c:) of your hard drive.

Get wget from:-

http://sourceforge.net/project/downloading.php?groupname=gnuwin32&filename=wget-1.11.4-1-setup.exe&use_mirror=garr

install it

open a cmd prompt e.g. start | run | type: cmd
in the command prompt type cd.. press enter

type this again till you get to just the c:

(The program may be located in a BIN folder, and if so, the likely path will be: C:\Program Files\GnuWin32\bin. At the c: prompt, type cd Program Files\GnuWin32\bin)

When you reach this location...

type wget -i c:\textfile.txt (replace textfile.txt with the name of the textfile you created)

let it run till it downloads all your images. (They will be saved into the bin folder, because that's where WGET is located, so later you can move them to another folder).

you will now have a folder with all the images as they were on the remote server.

You can then FTP the images to your own server.

16 Jan 2013, 4:48 PM
#11
alteredvision avatar

alteredvision

New Zenner

Join Date:
Feb 2010
Posts:
41
Plugin Contributions:
0

Re: Using external images

I just did this on a site because the customer was always having to update there site with the new images that were always changed by the manufacturer. There is also the fact that even with the steps above it was to much work for the customer.

I found an old thread on here where they talked about it in 2008 but some of there information was very outdated and since there was so many new changes I was able to do this very easy with only editing 1 file in a non-destructive way. If you try the way other posts say then it will work but your banner images will also be effected because they are all using the same HTML coding.

Here is what I did:
All edits are on - root/includes/functions/html_output.php

Step #1
First you have to edit the zen_image_OLD() function because you are going to use this to call in your images.
Find:
$image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';

Right above that add this line of code
//This cuts images/ out of the string when you are calling an external image
$src = substr($src, 7);

Step #2
Find the zen_image() function and look for:
if (strstr($src, 'includes/templates') or strstr($src, 'includes/languages') or PROPORTIONAL_IMAGES_STATUS == '0') {

Add to the end of that string the http check:
if (strstr($src, 'includes/templates') or strstr($src, 'includes/languages') or PROPORTIONAL_IMAGES_STATUS == '0' or stristr($src, 'http') != '0' ) {

That's it, now the site should be unaffected but when you call a external image with a http in front of it the code will use the other function removing the images/ part of the string. I have not tested this on more then products and banners and I am not sure where zen_image_OLD() is called. I did a simple search for it in the developer tool kit and did not find it. You could also just copy all of it and rename the function so that there is no interference at all.

16 Jan 2013, 6:54 PM
#12
alteredvision avatar

alteredvision

New Zenner

Join Date:
Feb 2010
Posts:
41
Plugin Contributions:
0

Re: Using external images

I forgot to mention that you have to add in enough space for the URL address in the database. Just put this in the "Install SQL Patch" under tools in the admin.

ALTER TABLE products CHANGE products_image products_image VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL;

16 Jan 2013, 7:24 PM
#13
alteredvision avatar

alteredvision

New Zenner

Join Date:
Feb 2010
Posts:
41
Plugin Contributions:
0

Re: Using external images

How embarrassing if you do this the images from your template will no longer show. Here is the fix so only the 'http' images get cut off.

if(stristr($src, 'http') ){
//This cuts images/ out of the string when you are calling an external image
$src = substr($src, 7);
}

16 Jan 2013, 8:03 PM
#14
alteredvision avatar

alteredvision

New Zenner

Join Date:
Feb 2010
Posts:
41
Plugin Contributions:
0

Re: Using external images

Going to have to still work on this one.
With the lightbox plugin installed the image will not come up. It works fine but will distort the image size because zen cart sets sizing.