Alt Tags missing

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
Post Reply
Tubs
Posts: 5
Joined: Mon Dec 14, 2009 6:28 pm

Alt Tags missing

Post by Tubs »

Hi We were recently forced to upgrade to version 5.5.4. due to a bug and we imported the products from the old store to the new store. Unfortunately we now have no Alt Tags. Does anyone know how we can fix this. Even if it just took the product name that would be better than manually having to go into each product to add the Alt tag
Thanks
Tubs :?:
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: Alt Tags missing

Post by Tony Barnes »

Have you updated the templates properly? The snippet /templates/_master/snippets/ProductThumbImage.html generates the alt tag and title, and should be called in all the relevant panels
anders
Posts: 4
Joined: Thu Sep 24, 2009 12:40 pm

Re: Alt Tags missing

Post by anders »

Hi Tony, do you mean that the image alt tags should be automatically generated in 5.5.4? I was of the impression that they are not automatically generated and that you will have to manually add them via the control panel which now as an image description field next to the image. It would certainly be great if the shopping cart automatically generated the image alt tags (by using to the product name) if the image description field was left empty but I don't think that is the case?

There is a simple modification in the forum that will generate image alt tags for products and catagories but the code in 5.5.4 has changed so much so am not sure if it can be used (it worked a treat in previous versions). Also, I would be worried it would cause conflicts in case image descriptions were added, for some products, via the control panel.

Thanks
Ola
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: Alt Tags missing

Post by Tony Barnes »

You know what, I'd never realised that!! How daft, I assumed it just pulled through the name...

Right, well for the product page you can simply change the file slightly. Copy /templates/_master/snippets/ProductThumbImage.html to /templates/YOUR TEMPLATE/snippets/ProductThumbImage.html and edit it as follows:
<div class="ProductThumbImage" style="width:%%GLOBAL_ProductThumbWidth%%px; height:%%GLOBAL_ProductThumbHeight%%px;">
<a style="margin:auto;" href="%%GLOBAL_ZoomImageURL%%" onclick="%%GLOBAL_TinyImageClickJavascript%% return false;">
<img src="%%GLOBAL_ThumbImageURL%%" alt="%%GLOBAL_ProductName%%" title="%%GLOBAL_ProductName%%" />
</a>
</div>
Just done that to ours and it works fine.

If I get time I'll have a look into hacking it in properly, as this will now renders the backend desciption bit useless. A simple logic check oughtn't be that hard
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: Alt Tags missing

Post by Tony Barnes »

Ok, figured I'd have a quick look, this one is brilliantly simple.

Open up includes/display/productdetails.php, go to around line 740 (mine is edited earlier on, so it will be around here you need to look), and find:
$GLOBALS['ImageDescription'] = isc_html_escape($productImage->getDescription());
if($GLOBALS['ImageDescription'] == '') {
$GLOBALS['ImageDescription'] = GetLang("Image") . " " . ($i + 1);
}
change it to this:
$GLOBALS['ImageDescription'] = isc_html_escape($productImage->getDescription());
if($GLOBALS['ImageDescription'] == '') {
$GLOBALS['ImageDescription'] = $GLOBALS['ProductName'];
}
If you have put in any manual descriptions it will use them, otherwise it will just revert to the product name. Simples :D
Post Reply