Product image with spaces in filename not loaded

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
pjs75
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Thu Jul 14, 2011 9:10 pm

Product image with spaces in filename not loaded

Post by pjs75 » Sun Dec 11, 2011 7:36 pm

For unknown reason, AC does not find some images in the Assets folder.

It appears to be file names that contain spaces.
Eg, look here:
http://www.thecountrycaregroup.com.au/V ... 08175.aspx

The image "SM 45011.jpg" ,"SM 45011_i.jpg" "SM 45011_t.jpg" does exist on the server.

I dug into the code ConLib/ProductImage.ascx.cs, and for unknown reason it just doesn't load the images. As I don't have the source code for AC, I cannot debug further.

See attachment showing

User avatar
david-ebt
Captain (CAPT)
Captain (CAPT)
Posts: 253
Joined: Fri Dec 31, 2010 10:12 am

Re: Product image with spaces in filename not loaded

Post by david-ebt » Mon Dec 12, 2011 11:50 am

What version of AC are you using? Spaces in image names is working okay for me.

However, you can modify the Conlib\ProductImage.ascx.cs code to explicitly change spaces to the HTML equivalent by doing this:

change:

Code: Select all

phProductImage.Controls.Add(new LiteralControl("<img id=\"ProductImage\" src=\"" + Page.ResolveUrl(imageUrl) + "\" border=\"0\" alt=\"" + Server.HtmlEncode(imageAltText) + "\" />"));
to:

Code: Select all

phProductImage.Controls.Add(new LiteralControl("<img id=\"ProductImage\" src=\"" + Page.ResolveUrl(imageUrl).Replace(" ","%20") + "\" border=\"0\" alt=\"" + Server.HtmlEncode(imageAltText) + "\" />"));
See if that fixes your problem.
David
http://www.ecombuildertoday.com
Enhanced Reporting for AbleCommerce
Image

pjs75
Ensign (ENS)
Ensign (ENS)
Posts: 20
Joined: Thu Jul 14, 2011 9:10 pm

Re: Product image with spaces in filename not loaded

Post by pjs75 » Tue Dec 13, 2011 6:33 pm

Hi David,
Thanks for the reply. I am using 7.0.7.14600. Just so its clear, this is using images based on SKU, from the Assets/ProductImages directory.

It's strange because it doesn't load the list of images into the Product images (see how there are no elements in the Product.Images property in the screenshot of debug).
It just doesn't load them!

I see this behaviour if the filename has equal sign, or space character.

I ended up writing some extra code to load them properly, though I have had to edit the website pages to integrate it. Not ideal, but at least my site looks OK now.
I had to edit CategoryGrid.ascx/cs FeaturedGrid.ascx/cs and ProductImage.ascx/cs - there's probalby couple that I still have to edit to complete the work. :-^

pat.

Post Reply