Page 1 of 1
Default image for missing pictures
Posted: Wed Sep 16, 2009 6:17 pm
by igavemybest
Is there a way to set a default image for missing pictures. Basically, doing a custom import, named all the images based off of the product number. For some products there is just not going to be an image, so I need to find a way to have a default behavior to a "no image" image, when the intended image is not available.
Suggestions?
Re: Default image for missing pictures
Posted: Thu Sep 17, 2009 5:13 am
by AbleMods
You'll have to modify the ProductImage conlib control to test for missing image(s) and set a static image file name.
Re: Default image for missing pictures
Posted: Thu Sep 17, 2009 6:32 am
by Mike718NY
Don't know if this helps but I use this in the
...../App_Data/Scriptlets/Custom/Content/Show Product 1.htm
file to display a link if there is no picture:
#if($Product.ImageUrl.Length==0)
<a class="ableStoreUL" href="Search.aspx?m=$Product.ManufacturerId">
<font class="ableStore15">$Product.Manufacturer.Name</font></a><br /><br />
#else
<a class="ableStoreUL" href="Search.aspx?m=$Product.ManufacturerId">
[[ConLib:ProductImage ShowImage="Image"]]</a>
#end
Re: Default image for missing pictures
Posted: Thu Sep 17, 2009 7:33 am
by igavemybest
See, the issue is that for all products, there is a link to an image, it is just a case where a lot of the files are not going to be there. I found these links, but am not sure how I would implement them in AC7
Check out this:
http://forums.asp.net/t/1358902.aspx
http://www.daniweb.com/forums/thread66187.html
Re: Default image for missing pictures
Posted: Sat Sep 19, 2009 3:47 am
by AbleMods
Able dynamically injects the product image while the page is being contructed, thus none of the "standard" solutions will work in your case.
The cheap way out is to export your catalog via dataport, use excel to populate all the blank product image fields with a path to your missing-image file and then use dataport to update the catalog. This only catches the current catalog and won't handle new products.
But you'll need 3 different sizes of the no-image image since the same productimage user control renders all 3 image sizes in the storefront.
If you want it to happen on-the-fly, read on....
Backup your ~/ConLib/ProductImage.ascx.cs file and replace the page_load() section with this code. Note you'll need to create 3 no-image images in your ~/Images/ folder or change the path references in the modified code below. This solution only works if Able hasn't auto-populated the image paths for each product. If they have been populated but the files themselves do not exist, more extensive programming would be necessary.
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
int _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
Product _Product = ProductDataSource.Load(_ProductId);
if (_Product != null)
{
string checkImage = this.ShowImage.ToLowerInvariant();
string imageUrl;
string imageAltText;
if (checkImage == "icon")
{
imageUrl = _Product.IconUrl;
imageAltText = _Product.IconAltText;
if (imageUrl == "") imageUrl = "~/images/noimage_icon.jpg";
}
else if (checkImage == "thumbnail")
{
imageUrl = _Product.ThumbnailUrl;
imageAltText = _Product.ThumbnailAltText;
if (imageUrl == "") imageUrl = "~/images/noimage_thumbnail.jpg";
}
else
{
imageUrl = _Product.ImageUrl;
imageAltText = _Product.ImageAltText;
if (imageUrl == "") imageUrl = "~/images/noimage_product.jpg";
}
if (!string.IsNullOrEmpty(imageUrl))
{
phProductImage.Controls.Add(new LiteralControl("<img id=\"ProductImage\" src=\"" + Page.ResolveClientUrl(imageUrl) + "\" border=\"0\" alt=\"" + Server.HtmlEncode(imageAltText) + "\" />"));
}
}
Re: Default image for missing pictures
Posted: Tue Sep 29, 2009 4:00 pm
by igavemybest
The issue here is that some products imported have images, some dont. In either case it would take a literal year to enter it all by hand, so when I built the csv importer to build my store, I set all the product images as the part numbers, so they all have a url. I have been thinking on this and I think I found somehting that mak wirk, but if you come up with anything else let me know.
Thx
Re: Default image for missing pictures
Posted: Wed Sep 30, 2009 11:43 am
by igavemybest
Ok...I got it working. A custom http handler was the solution that worked best for me. If the file exists is shows the called file, else it shows a default file.
Re: Default image for missing pictures
Posted: Tue Aug 16, 2011 7:31 am
by manville
igavemybest wrote:Ok...I got it working. A custom http handler was the solution that worked best for me. If the file exists is shows the called file, else it shows a default file.
Can you share the solution? I would like to do the same thing.
Thanks.