You are here:  » Displaying a default thumbnail


Displaying a default thumbnail

Submitted by womble on Fri, 2006-05-05 06:03 in

Im parsing a file with thumbnails for each item, however some items have no thumbnail. If the data in that field is blank how can I display a default image?

Im using this code..

print "(h2)(a href='".$item["ITEM/LISTINGDETAILS/VIEWITEMURL"]."')".$item["ITEM/TITLE"]."(/a)(/h2)";
print "(img src='".$item["ITEM/VENDORHOSTEDPICTURE/GALLERYURL"]."' /)";
print "(br /)(br /)";

Thanks

Submitted by support on Fri, 2006-05-05 06:07

Hi!

This should just be a case of testing the thumbnail (which I assume is the GALLERYURL item) for an empty string, and conditionally displaying the default image if it is empty. The following code should do the trick:

print "<h2><a href='".$item["ITEM/LISTINGDETAILS/VIEWITEMURL"]."'>".$item["ITEM/TITLE"]."</a></h2>";
if ($item["ITEM/VENDORHOSTEDPICTURE/GALLERYURL"])
{
  print "<img src='".$item["ITEM/VENDORHOSTEDPICTURE/GALLERYURL"]."' />";
}
else
{
  print "<img src='default.gif' />";
}
print "<br /><br />";

Hope this helps!
David.

Submitted by womble on Fri, 2006-05-05 07:55

Thanks David worked a treat!