You are here:  » Overwriting Merchants Images

Support Forum



Overwriting Merchants Images

Submitted by paddyman on Mon, 2009-05-18 16:29 in

Hi David,

Have searched the forum before posting, but couldn't find anything related to my question below......

Just wondering what would I have to change in products.php, to use my own images instead of merchant images as per your mod here http://www.pricetapestry.com/node/2699

Currently have in product.php but not too sure what to change !!

Many thanks

Adrian

Submitted by support on Mon, 2009-05-18 18:01

Hi Adrian,

Based on the modification described in that thread, to extend that to images try;

    if ($numRows)
    {
      $filename = "descriptions/".$rows[0]["name"].".txt";
      if (file_exists($filename))
      {
        $rows[0]["description"] = file_get_contents($filename);
      }
      $imageFilename = "localimages/".$rows[0]["name"].".jpg";
      if (file_exists($imageFilename))
      {
        $rows[0]["image_url"] = $config_baseHREF.$imageFilename;
      }

I've used the directory name "localimages" as Price Tapestry already has a folder called "images"; and assumed a file extension of ".jpg"; however this could be dropped if the images are not necessarily going to be of the same format as browsers are normally able to work out the image format regardless of the extension (in fact they try to do that first) - in which case save the local images with a filename exactly matching the procuct name and no extension; and instead of...

      $imageFilename = "localimages/".$rows[0]["name"].".jpg";

...just use:

      $imageFilename = "localimages/".$rows[0]["name"];

Cheers,
David.

Submitted by paddyman on Tue, 2009-05-19 11:16

Many thanks David.

Submitted by paddyman on Mon, 2009-06-08 15:14

Hi David,

Keeping you busy today:)

This mod is working great in my product pages producing nice clean custom images. Can you advise on where to place this or similar code in search.php in order to use the custom images as thumbnails.

Many thanks

Adrian

Submitted by support on Mon, 2009-06-08 15:44

Hi Adrian,

In search.php, the processing loop for each result where similar code could be added begins at line 162 as follows:

foreach($searchresults["products"] as $k => $product)
{

...so immediately inside the loop, i.e. after the opening "{", you could add:

      $imageFilename = "localimages/".$product["name"].".jpg";
      if (file_exists($imageFilename))
      {
        $searchresults["products"][$k]["image_url"] = $config_baseHREF.$imageFilename;
      }

Cheers,
David.