You are here:  » Missing Images


Missing Images

Submitted by ChrisNBC on Sun, 2014-03-02 22:27 in

Hi David,

Hope all is going well.

I wondered if you may be able to help me resolve something rather odd that is happening on the site I have been working on.In suummary, I noticed last week that some product images were not being displayed on my featured (index)pages, but then when I select a product with a missing image the linked product page shows images. I have also noticed that some featured products with images can have missing images on the linked product page. I implemented the image cache solution described in node 279 thinking this may help resolve the issue but it's had little impact.

Would be grateful for any suggestions you might have on how I might resolve this issue.

Thanks in advance.

Regards
Chris

Submitted by support on Mon, 2014-03-03 08:28

Hi Chris,

What's almost certainly happening there is that an item is compared (more than 1 merchant), but not all merchants have images, and the `image_url` selected by the summary query that generates the Featured Products results happened to be one of the merchants without an image.

A simple solution is to re-query for an image_url for any featured product record that has an empty `image_url` field - to do this, simply add the following code to the very top of html/product.php

<?php
  
foreach($featured["products"] as $k => $product)
  {
    if (!
$product["image_url"] && ($product["numMerchants"] > 1))
    {
      
$sql "SELECT image_url FROM `".$config_databaseTablePrefix."products` WHERE name='".database_safe($product["name"])."' AND image_url <> ''";
      if (
database_querySelect($sql,$rows))
      {
        
$featured["products"][$k]["image_url"] = $rows[0]["image_url"];
      }
    }
  }
?>

If you encounter a similar situation with search results, almost exactly the same code can be used at the top of html/searchresults.php - just replace $featured with $searchresults

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Mon, 2014-03-03 09:49

Hi David,

Hope you had a good weekend. Thanks for the above code.

I implemented the code but when I click on an image now, the error below is diaplayed:

"Fatal error: Only variables can be passed by reference in /home/content/43/10000000/html/Sites/MySite/pt/pt/html/product.php on line 7"

Please could you suggest how to resolve this.

Thanks in advance.

Regards
Chris

Submitted by support on Mon, 2014-03-03 09:55

Hi Chris, sorry about that;

"rows" in line 7 should have been "$rows" - corrected above...

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Mon, 2014-03-03 10:31

Hi David,

Thanks for the quick response. I modified the code as you suggested but now get the error below displayed:

"Warning: Invalid argument supplied for foreach() in /home/content/43/10000000/html/Sites/MySite/pt/pt/html/product.php
on line 2"

Would be grateful if you could suggest how I can resolve this.

Thanks in advance.

Regards
Chris

Submitted by support on Mon, 2014-03-03 10:41

Hi Chris,

It looks from the error message as if the wrong file has been modified - error is referring to html/product.php, but for the Featured Products images it should be added to html/featured.php - that should be all it is, but if you are having similar issues on the product page (e.g. with Related Products) that would be a case of applying the same modification to html/searchresults.php as described above (replacing $featured with $searchresults)...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Mon, 2014-03-03 18:17

Hi David,

Sorry, I must be missing something because I (**think I **) applied the changes as per above and am still getting the error:

{code saved}

Would be grateful if you could maybe take a look at the pages and let me know what you think.

Thanks in advance.

Regards
Chris

Submitted by support on Mon, 2014-03-03 18:26

Hi Chris,

Please could you email me the following files:

index.php
html/product.php
html/featured.php

...and I'll check it all out for you - I assume image problem regarding Featured Products is on home page only - let me know if that's not the case and you've added code to include Featured Products elsewhere...

Cheers,
David.
--
PriceTapestry.com