Default image for missing pictures

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

Default image for missing pictures

Post by igavemybest » Wed Sep 16, 2009 6:17 pm

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?

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Default image for missing pictures

Post by AbleMods » Thu Sep 17, 2009 5:13 am

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

Mike718NY
Commodore (COMO)
Commodore (COMO)
Posts: 485
Joined: Wed Jun 18, 2008 5:24 pm

Re: Default image for missing pictures

Post by Mike718NY » Thu Sep 17, 2009 6:32 am

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

User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

Re: Default image for missing pictures

Post by igavemybest » Thu Sep 17, 2009 7:33 am

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

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Default image for missing pictures

Post by AbleMods » Sat Sep 19, 2009 3:47 am

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) + "\" />"));
            }
        }
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

User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

Re: Default image for missing pictures

Post by igavemybest » Tue Sep 29, 2009 4:00 pm

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

User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

Re: Default image for missing pictures

Post by igavemybest » Wed Sep 30, 2009 11:43 am

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.

manville
Ensign (ENS)
Ensign (ENS)
Posts: 2
Joined: Fri Apr 08, 2011 7:18 am

Re: Default image for missing pictures

Post by manville » Tue Aug 16, 2011 7:31 am

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.

Post Reply