You are here:  » uploading logos


uploading logos

Submitted by wilkins on Wed, 2013-08-07 15:36 in

Hi David

Sorry, forgot to ask in last post. We are using the upload logos script, however, because we are uploading a lot, it became very slow, is there any way that then uploading for the logos not to show on the page?

Brent

Submitted by support on Wed, 2013-08-07 15:51

Hi Brent,

I remember sending you a version of admin/merchant_logos.php with the upload form at the top, I'll re-send that for the latest distribution for you...

Cheers,
David.
--
PriceTapestry.com

Submitted by sbedigital on Sun, 2013-08-11 00:58

Sorry to butt in here, i had an idea i thought i woukd like to share. What if modify the logo script s that it detects all uploaded logis. What i mean is;

Assume i have folder called logo and i have renamed all the logs so that filename matches exactly to the merchant name. Now after uploading these logos in the logo folder via ftp, then go to logo uploading section of the admin - beside having option of uploading logos, can we have the script to detect existing logos by scanning the logo folder and give the admin user instant feedback like as follows:

Merchant. . Logo fie
------------------------

Argos. . argos.jpg
ASDA. . Aasda.jpg

...and so on

And if the merchant des not have logo then beside that merchant can we have a upload box, so that user can click tell the script location of the logo and finally have a global upload button right at the bottom. Once pressed all the upload files will be actioned same way your exsiting script does.

Optionally, you can make script in away so that rather than fiddling with the main script you declare the logo folder locatio, logo file type in the main config.php file like:

 $logo_folder = location/to/logo/folder;
$logo_type = jpg or png or gif;
 

Submitted by support on Sun, 2013-08-11 12:36

Hi sbedigital,

That is basically how it works - merchant logo inclusion, both on the admin page and where the logo is displayed on user pages is based on file_exists() looking for /logos/Merchant Name, with the logo displayed if exists...

Cheers,
David.
--
PriceTapestry.com

Submitted by sbedigital on Sun, 2013-08-11 18:06

Hi Dave,

I have noticed to automatically detect the logo these logo files needs to be exact match of the registered merchant name. I just wonder script can modified slightly to have file extention for the logo images. For example on default setup a logo for Merchant "ASDA" will be the logo file "ASDA", would it be possible to have logo file name as "ASDA.PNG" or even better detect all posibble varation of, which mean script looks for all image extentions like ASDA.gif, ASDA.jpg, ASDA.png etc to see if they exist.

Reason for this is, I have fonund that some of the devices (especially mobile devices) does not render the images or the transparency values properly, also inserting images without extension seems to be an big issue WC3 HTML validation.

Submitted by support on Mon, 2013-08-12 08:06

Hello noor,

Sure - the first thing to do would be to create a new utility function to test for the logo file based on an array of standard file extensions. To do this, add the following code to includes/tapestry.php

  function tapestry_getLogoFilename($merchant)
  {
    $extensions = array("gif","jpg","png");
    foreach($extensions as $extension)
    {
      $filename = "logos/".$merchant.$extension;
      if (file_exists($filename))
      {
        return $filename;
      }
    }
    return "";
  }

And then to use the returned value if set, in html/prices.php look for the following code around line 11:

<?php print (file_exists("logos/".$product["merchant"])?"<img src='".$config_baseHREF."logos/".$product["merchant"]."' border='0' />":$product["merchant"]); ?>

...and REPLACE with:

<?php print ($logoFilename tapestry_getLogoFilename($product["merchant"]))?"<img src='".$config_baseHREF.$logoFilename."' border='0' />":$product["merchant"]); ?>

And then for Merchant Logos administration, in admin/merchant_logos.php look for the following code at line 45:

  $logoFilename = "../logos/".$row["merchant"];
  if (file_exists($logoFilename))

...and REPLACE with:

  $logoFilename = tapestry_getLogoFilename($row["merchant"]);
  if ($logoFilename)

...and finally the following code at line 60:

  print "<td><img style='padding:10px;' src='".$config_baseHREF."logos/".$row["merchant"]."' /></td>";

...and REPLACE with:

  print "<td><img style='padding:10px;' src='".$config_baseHREF.$logoFilename."' /></td>";

Cheers,
David.
--
PriceTapestry.com

Submitted by stevebi on Mon, 2015-04-20 00:43

Hi David,

Could you please help me in applying the above modification in version 14/06A.

I applied includes/tapestry.php

In html/prices.php how should I modify the following code

<?php if (file_exists("logos/".$price_product["merchant"])): ?>
<td class='pt_pr_mlogo'><a title='<?php print htmlspecialchars($price_product["merchant"],ENT_QUOTES,$config_charset); ?>' href='<?php print tapestry_buyURL($price_product); ?>'><img width='120' height='60' alt='<?php print htmlspecialchars($price_product["merchant"],ENT_QUOTES,$config_charset); ?> <?php print translate("Logo"); ?>' src='<?php print $config_baseHREF."logos/".str_replace(" ","%20",$price_product["merchant"]); ?>' /></a></td>

And in admin/merchant_logos.php

print "<td><img style='padding:10px;' src='".$config_baseHREF."logos/".str_replace(" ","%20",$row["merchant"])."' alt='".htmlspecialchars($row["merchant"],ENT_QUOTES,$config_charset)." Logo' /></td>";

Thank you for your support

Cheers

Steve

Submitted by stevebi on Mon, 2015-04-20 01:01

Hi David,

Just to ddouble check

The following code will be applied before the closing ?>

  function tapestry_getLogoFilename($merchant)
  {
    $extensions = array("gif","jpg","png");
    foreach($extensions as $extension)
    {
      $filename = "logos/".$merchant.$extension;
      if (file_exists($filename))
      {
        return $filename;
      }
    }
    return "";
  }

Cheers

Steve

Submitted by support on Mon, 2015-04-20 08:55

Hi Steve,

Yes - add the tapestry_getLogoFilename($merchant) function to the end of includes/tapestry.php, just before the closing ?> tag.

With that in place, the replacement to the code you posted from your html/prices.php would be:

<?php
  $logoFilename = tapestry_getLogoFilename($price_product["merchant"]);
  if ($logoFilename):
?>
<td class='pt_pr_mlogo'><a title='<?php print htmlspecialchars($price_product["merchant"],ENT_QUOTES,$config_charset); ?>' href='<?php print tapestry_buyURL($price_product); ?>'><img width='120' height='60' alt='<?php print htmlspecialchars($price_product["merchant"],ENT_QUOTES,$config_charset); ?> <?php print translate("Logo"); ?>' src='<?php print $config_baseHREF."logos/".$logoFilename?>' /></a></td>

Also in merchants.php look for the following code beginning at line 16:

  if (file_exists("logos/".$product["merchant"]))
  {
    $item["logo"] = $config_baseHREF."logos/".str_replace(" ","%20",$product["merchant"]);
  }

...and REPLACE with:

  $logoFilename = tapestry_getLogoFilename($product["merchant"]);
  if (file_exists("logos/".$logoFilename))
  {
    $item["logo"] = $config_baseHREF."logos/".$logoFilename;
  }

Modifications required to admin/merchant_logos.php:

Look for the following code at line 14:

  if (move_uploaded_file($_FILES['image']['tmp_name'],"../logos/".$_POST["merchant"]))

..and REPLACE with:

  $parts = explode(".",$_FILES['image']['name']);
  $extension = $parts[count($parts)-1];
  $logoFilename = $_POST["merchant"].".".$extension;
  if (move_uploaded_file($_FILES['image']['tmp_name'],"../logos/".$logoFilename))

Then for the existing logos display, look for the following code at line 44:

      $logoFilename = "../logos/".$row["merchant"];
      if (file_exists($logoFilename))

...and REPLACE with:

      $logoFilename = tapestry_getLogoFilename($row["merchant"]);
      if ($logoFilename)
      {

And finally the following code at line 56:

  print "<td><img style='padding:10px;' src='".$config_baseHREF."logos/".str_replace(" ","%20",$row["merchant"])."' alt='".htmlspecialchars($row["merchant"],ENT_QUOTES,$config_charset)." Logo' /></td>";

...and REPLACE with:

  print "<td><img style='padding:10px;' src='".$config_baseHREF."logos/".tapestry_getLogoFilename($row["merchant"])."' alt='".htmlspecialchars($row["merchant"],ENT_QUOTES,$config_charset)." Logo' /></td>";

Cheers,
David.
--
PriceTapestry.com

Submitted by stevebi on Mon, 2015-04-20 09:24

Thanks you for all the modifications David!!!

They are going to be very helpful for WC3 HTML.

Just add "function" at at the beginning of includes/tapestry.php code

:-)

Cheers

S

Submitted by support on Mon, 2015-04-20 09:27

Oops, well spotted - corrected above.

Cheers,
David.
--
PriceTapestry.com

Submitted by stevebi on Mon, 2015-04-20 19:01

Hi David,

Could you please help me at the following.

When I upload an image logo, it retrieves Merchants name as image file name. So that might be "Merchant Name.jpg" and will look like /logos/Merchant Name.jpg

How can I keep image name because if there is a space at Merchants name it is not validated at W3C HTML.

Cheers

Steve

Submitted by support on Tue, 2015-04-21 07:29

Hi Steve,

The merchant name can be hyphenated easily. Have a go with the following
alternative tapestry_getLogoFilename() function replacing the version
above in includes/tapestry.php:

  function tapestry_getLogoFilename($merchant)
  {
    $extensions = array(".gif",".jpg",".png");
    foreach($extensions as $extension)
    {
      $filename = tapestry_hyphenate($merchant).$extension;
      if (file_exists((is_dir("logos")?"logos/":"../logos/").$filename))
      {
        return $filename;
      }
    }
    return "";
  }

And in admin/merchant_logos.php look for the following line in the first replacement:

   $logoFilename = $_POST["merchant"].".".$extension;

...and REPLACE with:

   $logoFilename = tapestry_hyphenate($_POST["merchant"]).".".$extension;

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by stevebi on Tue, 2015-04-21 07:49

Thank you very much David!!!!

Both for great and fast support!!

One question should I upload all the logo images again?
or just the ones with the spaces?

Cheers

S

Submitted by support on Tue, 2015-04-21 07:50

Hi Steve,

Thank you for your comments!

You'll only need to re-upload those containing spaces, in all other cases filename will be the same.

Cheers,
David.
--
PriceTapestry.com

Submitted by stevebi on Tue, 2015-04-21 09:34

Everything worked perfect David!!

Thank you very much

S