Easy way to edit Alt Text for images?

This doesn’t seem to be something in the export list so I’m not sure if there is an easy way to do this. None of my images have alt text and I think it may be beneficial to at least change them to the product titles. With 4000+ products this can be quite time consuming. ESPECIALLY when a page of 100 didn’t post. I had about 10% done when that little glitch happened forcing me to lose about 15 minutes of work. Figured there has to be a better way than copy and pasting each one individually.

There is a post that was posted some time ago that added code so that the product name would automatically be used for alt text. Do a search and also be forewarned that it may or may not work with the latest version.

May be this



[url]http://forum.cs-cart.com/showthread.php?t=13245[/url]

[quote name=‘johnbol1’]May be this



[url]http://forum.cs-cart.com/showthread.php?t=13245[/url][/QUOTE]



Yes, that is one way but there was another one that was a mod that automatically did it itself.

more simple, use in admin the mass edit product and select pair picture

[quote name=‘creativeuser’]more simple, use in admin the mass edit product and select pair picture[/quote]



That’s what I was doing but with 4000+ products it’s gonna take a while. Especially when the last 100 I modified didn’t post. So that was about 15 minutes worth of work down the drain. Was hoping to randomly avoid this type of “ooops”.

You can do this by modifying:



skins/your-skin/customer/common_templates/image.tpl



Change:


{if !(($object_type == "category" || $object_type == "detailed_category") && !$icon_image_path)}
{$images.icon.alt|default:$images.detailed.alt}
{/if}




To:


{if !(($object_type == "category" || $object_type == "detailed_category") && !$icon_image_path)}
{$product.product|unescape}
{/if}




If you also want to add a title than change it to:


{if !(($object_type == "category" || $object_type == "detailed_category") && !$icon_image_path)}
{$product.product|unescape}
{/if}




Hope that helps,



Brandon

Awesome Brandon, Thanks!

While my code does work The Tool posted a better chunk of code on a different thread. I really like how he used an if statement for the alt. This way, if you manually enter the alt, it will still show up whereas my code will just overwrite it.



The thread he did is at [url]http://forum.cs-cart.com/showthread.php?t=23972[/url]



I went ahead and took his code an added to it though. My code below not only adds the alt tag, but also includes a title tag.



In skins/your-skin/customer/common_templates/image.tpl



Replace:


{if !(($object_type == "category" || $object_type == "detailed_category") && !$icon_image_path)}
{$images.icon.alt|default:$images.detailed.alt}
{/if}




With:


{if !(($object_type == "category" || $object_type == "detailed_category") && !$icon_image_path)}

{/if}




Thanks,



Brandon

I just added this to one of our sites. I like what it does. Simple, but needed.

Finally had time to look at the code. Since I’m on 2.0.11 my image.tpl doesn’t have that line of code. It’s a little different:


{if !($object_type == "category" && !$icon_image_path)}
{$images.icon.alt}
{/if}




Not too worried about it since I will be upgrading soon.

Hmmm…maybe I’m missing something but I changed the code on a site I am running 2.1.4 and it didn’t seem to do anything. Tried both types of code (Tool’s too) with neither showing up in the image info or when viewing the source code. This seems pretty straightforward so don’t think I could’ve screwed anything up.



Example: [url]http://www.slimphonecases.com/transparent-red-hard-plastic-bumper.html[/url]

I did Brandons and is OK on mine this is my source 2.1.4

[HTML]11001X Fire Extinguisher down sign (200x100mm Rigid Plastic)

View larger image



[/HTML]

JOhn

This is one of those things that is going to drive me insane. Something so simple but doesn’t work for me. Obviously it works…but not for me.

Clear cache

[quote name=‘The Tool’]Clear cache[/quote]



Haha! I knew it was something simple. Didn’t think about that one though (even after refresh, clear history, different computer, etc.). I guess my mind was somewhere else. Thanks!

Any idea why my product pages are showing 2 different titles (on another site of mine)? I assumed it has something to do with this mod which is why I posted here. Example: http://www.fastdecals.com/shop/people-careers-decals/baseball-player-05-decal-sticker.html



It seems all my products show the title of the product in red (above the image) and in normal text color (next to the image). Maybe I doubled up two different modified codes? Essentially I would like to eliminate one for SEO purposes (and to make it look cleaner).

Has anyone found a way to do this in 2.2.4 ??? Code is different… Thanks for any help…