Forums / Templates, Stylesheets, Page Layout / Need to display different alt text for additional images on product info page

Need to display different alt text for additional images on product info page

Started by gills on 11 Feb 2013, 1:22 PM · Views: 1,599

Results 1 to 11 of 11
11 Feb 2013, 1:22 PM
#1
gills avatar

gills

New Zenner

Join Date:
Jan 2009
Location:
Ipswich, Suffolk UK
Posts:
6
Plugin Contributions:
0

Need to display different alt text for additional images on product info page

We sell plants, often these have varieties, each of which has its own image with its own alt tag.

What I am trying to achieve is the alt text for additional images to reflect their full correct and full file name as it does for the main image.

On the product info page for a particular plant, Zen Cart displays the same alt txt as for the main image, which is confusing for customers.

I have replaced:

$products_name
with
str_replace(array($products_image_base,$products_image_extension),'',$file)

as per thread 180191

which gets me half way there:

http://www.shrublandparknurseries.co.uk/shop/index.php?main_page=product_info&cPath=9&products_id=1224

shows the problem - ideally I need the 2 images at the bottom to show:

Justicia carnea & Justicia carnea 'Alba' respectively.

I also need the same solution for the pop up images for these additional images.

Any help would be much appreciated. My knowledge of php is very basic!

11 Feb 2013, 1:30 PM
#2
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Need to display different alt text for additional images on product info page

GillS:

We sell plants, often these have varieties, each of which has its own image with its own alt tag.

What I am trying to achieve is the alt text for additional images to reflect their full correct and full file name as it does for the main image.

On the product info page for a particular plant, Zen Cart displays the same alt txt as for the main image, which is confusing for customers.

I have replaced:

$products_name
with
str_replace(array($products_image_base,$products_image_extension),'',$file)

as per thread 180191

which gets me half way there:

http://www.shrublandparknurseries.co.uk/shop/index.php?main_page=product_info&cPath=9&products_id=1224

shows the problem - ideally I need the 2 images at the bottom to show:

Justicia carnea & Justicia carnea 'Alba' respectively.

I also need the same solution for the pop up images for these additional images.

Any help would be much appreciated. My knowledge of php is very basic!

I dont htink you will ever achive what you are trying to achive. simply becasue additional images are show based on files name.

so you would have main image:
Justicia carnea.jpg
then additionals would be
Justicia carnea_a.jpg
Justicia carnea_b.jpg

the only way you could have custom alt text is as per the method you are tring which is to use the text fom an image name, however as soon as you start renaming stuff and loose a file naming convetion whatever it may be you will loose the additional images..

what is it so imporatant that your alt text is set in this way? what do you feel you will gain from this?

Phil Rogers
A problem shared is a problem solved.

11 Feb 2013, 1:47 PM
#3
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Need to display different alt text for additional images on product info page

This is not possible with the current Additional Images system - which regards the additional images as supplementary (supportive) of the main image. Typically they are used to show a product from a different view / perspective (such as "front" and "back" of a garment).

You may get a better result by looking at a cross-sell module, which will showcase the variant as a separate product, on the product info page in question.

Scott Wilson (swguy) has written some cross-sell modules and a PM to him may suggest a way forward.

20 years a Zencart User

11 Feb 2013, 2:42 PM
#4
gills avatar

gills

New Zenner

Join Date:
Jan 2009
Location:
Ipswich, Suffolk UK
Posts:
6
Plugin Contributions:
0

Re: Need to display different alt text for additional images on product info page

Thankyou Phil - even "Justicia carnea_a.jpg" would do, perhaps you could point me in the right direction for doing this? I'd like it to be more obvious to the prospective customer to see that there are different varieties of the same plant, in most cases different flowers colours. I think this is more important to them, than it is to me. Just a thought - on our home page the featured plants (products) at the bottom have the correct alt text, that's what put me in mind for doing the same on the prod info page.

11 Feb 2013, 3:40 PM
#5
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Need to display different alt text for additional images on product info page

GillS:

Thankyou Phil - even "Justicia carnea_a.jpg" would do, perhaps you could point me in the right direction for doing this? I'd like it to be more obvious to the prospective customer to see that there are different varieties of the same plant, in most cases different flowers colours. I think this is more important to them, than it is to me. Just a thought - on our home page the featured plants (products) at the bottom have the correct alt text, that's what put me in mind for doing the same on the prod info page.

you could just use the filename and use string replace to remove the .jpg ?

but as schoolboy has pointed out, additinal images are intended as additional views of the same item generally, but I guess if you are selling different variations using attributes that could work too. I am assuming this is what you are trying to do? trying to match the image to an attribute option?

if so, it would probbaly be better to as well as using alt text maybe output some text under the image aswell.

so for your alt you probably want to do something like:

$products_name = str_replace(".jpg","",$file);

$script_link = '<script language="javascript" type="text/javascript"><!--' . "\n" . 'document.write(\'' . ($flag_display_large ? '<a href="javascript:popupWindow(\\\'' . str_replace($products_image_large, urlencode(addslashes($products_image_large)), $large_link) . '\\\')">' . $thumb_slashes . '<br />' . TEXT_CLICK_TO_ENLARGE . '<br />' . $products_name . '</a>' : $thumb_slashes) . '\');' . "\n" . '//--></script>';

    $noscript_link = '<noscript>' . ($flag_display_large ? '<a href="' . zen_href_link(FILENAME_POPUP_IMAGE_ADDITIONAL, 'pID=' . $_GET['products_id'] . '&pic=' . $i . '&products_image_large_additional=' . $products_image_large) . '" target="_blank">' . $thumb_regular . '<br /><span class="imgLinkAdditional">' . TEXT_CLICK_TO_ENLARGE . '</span><br />' . $products_name . '</a>' : $thumb_regular ) . '</noscript>';

not tested.. backup before you try this..

Phil Rogers
A problem shared is a problem solved.

11 Feb 2013, 3:44 PM
#6
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Need to display different alt text for additional images on product info page

alternativly, never used it before but pretty sure you can assign images to attributes and display them? maybe someone else that has done that before can advise you on that one..

Phil Rogers
A problem shared is a problem solved.

11 Feb 2013, 5:13 PM
#7
gills avatar

gills

New Zenner

Join Date:
Jan 2009
Location:
Ipswich, Suffolk UK
Posts:
6
Plugin Contributions:
0

Re: Need to display different alt text for additional images on product info page

Thanks schoolboy, I see what you mean. I am (probably incorrectly) using additional images to display different products/plants rather than attributes of a single product. When I get some time I'll check out the cross-sell module.

11 Feb 2013, 5:26 PM
#8
gills avatar

gills

New Zenner

Join Date:
Jan 2009
Location:
Ipswich, Suffolk UK
Posts:
6
Plugin Contributions:
0

Re: Need to display different alt text for additional images on product info page

As per my reply to schoolboy, I'm using the additional images to display different plants/products rather then attributes of one product. These plants are separate entities, just biologically related.

I'll try the code - in which file and where do I put the code? I will back up first!

11 Feb 2013, 5:41 PM
#9
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Need to display different alt text for additional images on product info page

I don't think the "alt" tag is populated within attribute image swatches - so it is not a viable alternative.

I still think the best way to go is a cross-sell module. Mainly because it is good for business. You can showcase related products against each other and either up-sell the customer, or point them to the second / third / fourth variant.

As Cross-sell uses product data, it will create an appropriate ALT tag for its image.

20 years a Zencart User

11 Feb 2013, 6:21 PM
#10
philip937 avatar

philip937

Totally Zenned

Join Date:
Aug 2009
Location:
Bedford, England
Posts:
968
Plugin Contributions:
0

Re: Need to display different alt text for additional images on product info page

swguy stuff is the way forward, I use a few I the mods he does and they are the bees knees!

I also use better together in connection with multi cross sell, so it allows me to cross sell in more than one way.

Phil Rogers
A problem shared is a problem solved.

12 Feb 2013, 12:18 AM
#11
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Re: Need to display different alt text for additional images on product info page

If your additional images are not referring to other actual products you sell, but are relevant as alternatives or whatever to the current product, you could use Additional Image Titles from Plugins to assign titles to each additional image. This is not related to alt tags; it gives text output above or below each additional image as desired.