You are here:  » Import Images


Import Images

Submitted by rickdebruin on Mon, 2012-10-01 08:20 in

Hi David,

Do you know if there is a simple way to import merchant images to my server instead of calling the image url?

Thanks
Rick

Submitted by support on Mon, 2012-10-01 09:20

Hello Richard,

There is an image caching script for standalone Price Tapestry described here:

http://www.pricetapestry.com/node/279

With that in place (for your /pt/ installation) you could then adapt the plugin to make use of the cache as follows. For search results and featured products, in both pto_search.php at line 453 and pto_featured.php at line 81 look for the following code:

  $each = str_replace("%IMAGE_URL%",$row->image_url,$each);

...and REPLACE with:

  global $pto_config_externalBaseHREF;
  $each = str_replace("%IMAGE_URL%",$pto_config_externalBaseHREF."imageCache.php?src=".urlencode($row->image_url),$each);

And for the main product image; look for the following code at line 303:

  $html_product = str_replace("%IMAGE_URL%",$product->image_url,$html_product);

...and REPLACE with:

  global $pto_config_externalBaseHREF;
  $html_product = str_replace("%IMAGE_URL%",$pto_config_externalBaseHREF."imageCache.php?src=".urlencode($product->image_url),$html_product);

The default image cache script uses a default cache period of 7 days (search for the constant 604800 which is the cache period in seconds if you wish to change this), and keep a close eye on disk usage; especially if your site is large and merchant images also! You may want to consider adding a line to empty the cache folder as part of your CRON fetch / import process - let me know if you're not sure about any part of the implementation of course;

Hope this helps!

Cheers,
David.
--
PriceTapestry.com