If this is your first visit, check our documentation. To post, register or login.

Alt tags in category images

Started by nick1973 on 26 Mar 2013, 10:45 AM · Views: 1,992

Results 1 to 7 of 7
26 Mar 2013, 10:45 AM
#1
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Post #1 by nick1973

Does anyone know how I would go about adding the category name into category images that have been uploaded through the admin?

I know this has been asked before and I'm aware that it may not be critical for SEO but there are some situations where it would help.

Currently my image code is like this:

<img src="images/categories/my-category-name.png" alt="" width="680" height="304" />

for the category image. Zen Cart does not seem to add an alt tag by default to category images.

What I would like is:

<img src="images/categories/my-category-name.png" alt="My Category Name" width="680" height="304" />

There must be some way of doing this easily by adding the category name inside an alt tag in the code that generates <img src="images/categories/my-category-name.png" alt="" width="680" height="304" />

Thanks

Nick

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

26 Mar 2013, 2:57 PM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Post #2 by ajeh

I am not sure what file you are in for that, but for the default code for Categories you can customize the file:
/includes/templates/your_template_dir/tpl_index_categories.php

with the code in RED:

// categories_image
  if ($categories_image = zen_get_categories_image($current_category_id)) {
[B]    $cat_name = zen_get_category_name($current_category_id, (int)$_SESSION['languages_id']);
[/B]?>
<div id="categoryImgListing" class="categoryImg"><?php echo zen_image(DIR_WS_IMAGES . $categories_image, [B]$cat_name[/B], SUBCATEGORY_IMAGE_TOP_WIDTH, SUBCATEGORY_IMAGE_TOP_HEIGHT); ?></div>
<?php

and the file:
/includes/templates/your_template_dir/tpl_index_product_listing.php

// categories_image
[B]    $cat_name = zen_get_category_name($current_category_id, (int)$_SESSION['languages_id']);
[/B]  if ($categories_image = zen_get_categories_image($current_category_id)) {
?>
<div id="categoryImgListing" class="categoryImg"><?php echo zen_image(DIR_WS_IMAGES . $categories_image, [B]$cat_name[/B], CATEGORY_ICON_IMAGE_WIDTH, CATEGORY_ICON_IMAGE_HEIGHT); ?></div>
<?php

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

27 Mar 2013, 12:22 AM
#3
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Post #3 by nick1973

THanks Linda will give this a go :-)

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

30 Mar 2013, 8:56 PM
#4
nick1973 avatar

nick1973

Totally Zenned

Join Date:
Sep 2008
Location:
Cleethorpes
Posts:
1,230
Plugin Contributions:
3

Post #4 by nick1973

How would I go about adding title tags into the navMain links that appear usually at the top of a zen site? (Home, Log in, My Account etc)

I've changed the name of the 'home' link to a search term. So 'Home' has become 'My Search Term' and I'd also like to put 'My Search Term' in the title tag of the 'Home' link.

Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk

6 Apr 2017, 11:40 AM
#5
bramf avatar

bramf

New Zenner

Join Date:
Apr 2017
Location:
Netherlands
Posts:
20
Plugin Contributions:
0

Post #5 by bramf

Why is this solution for proper alt tages on categories names not incorporated in standard zen-cart release?
Do you also have similar solution for manufacturers?

6 Apr 2017, 1:17 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #6 by mc12345678

bramf:

Why is this solution for proper alt tages on categories names not incorporated in standard zen-cart release?
Do you also have similar solution for manufacturers?
Possibly because no one has submitted the code to the core team for incorporation. Such discussion and action can occur at https://github.com/zencart/zencart. Additionally, no response was provided that the suggestion was a success. Further, not sure why an image is being presented that doesn't have an alt tag. I don't mean technically (the code), but why it was not considered necessary to include or why if there was a specific reason to not include the alt tag...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

6 Apr 2017, 1:43 PM
#7
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,146
Plugin Contributions:
56

Post #7 by lat9

@bramf, I don't know what Zen Cart version you're asking about, but certainly the most recent (Zen Cart 1.5.5a and later) includes those alt tags on category-listings; see my demo site for verification.

If you're not seeing them on your site, check your current template for those omissions.