Default image for missing pictures
- igavemybest
- Captain (CAPT)
- Posts: 388
- Joined: Sun Apr 06, 2008 5:47 pm
Default image for missing pictures
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?
Suggestions?
Re: Default image for missing pictures
You'll have to modify the ProductImage conlib control to test for missing image(s) and set a static image file name.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com
Re: Default image for missing pictures
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
...../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
- igavemybest
- Captain (CAPT)
- Posts: 388
- Joined: Sun Apr 06, 2008 5:47 pm
Re: Default image for missing pictures
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
Check out this:
http://forums.asp.net/t/1358902.aspx
http://www.daniweb.com/forums/thread66187.html
Re: Default image for missing pictures
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.
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) + "\" />"));
}
}
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com
- igavemybest
- Captain (CAPT)
- Posts: 388
- Joined: Sun Apr 06, 2008 5:47 pm
Re: Default image for missing pictures
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
Thx
- igavemybest
- Captain (CAPT)
- Posts: 388
- Joined: Sun Apr 06, 2008 5:47 pm
Re: Default image for missing pictures
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
Can you share the solution? I would like to do the same thing.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.
Thanks.