Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Adding alt text to an image

Adding alt text to an image

Locked

Views: 7,206

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
8 Oct 2009, 8:36 PM
#1
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Adding alt text to an image

** I want to change the image alt to repeat the product description instead of the title on the product listing page. **

I think I have it narrowed down to changing the section in html_output.php

if (zen_not_null($alt)) {
$image .= ' title=" ' . zen_output_string($alt) . ' "';
}

I think I need to rephrase the $alt with something along the lines of:

. zen_trunc_string(/zen_clean_html/(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) .

or

. zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($new_products->fields['products_id'], $_SESSION['languages_id']))), 150));

this does not seem to be working.

I currently have the description showing on the product listing (category) page. I want to cut out the actual text on the page (I can do this with no problem because I am the one who put it there) and make it show as alternate text (I cannot figure out how to do this). I am then going to add pictures of my attributes in place of the actual text on the page (I figured that out already also).

Does anyone know how to write the code to replace the alt text for the image with the product description (that is on the product info page in a stock zen cart)?

I have tried searching and I can't find a relevant post. If there is one, please direct me to the link. Thanks in advance.

14 Jan 2010, 6:01 PM
#2
hippyju avatar

hippyju

New Zenner

Join Date:
Jan 2010
Posts:
9
Plugin Contributions:
0

Re: Adding alt text to an image

Hi there,
How do I add alt text to my uploaded images on Zen Cart?
Many thanks,
Julie

14 Jan 2010, 6:09 PM
#3
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,611
Plugin Contributions:
0

Re: Adding alt text to an image

Which images specifically? Most are created automagically.

14 Jan 2010, 10:11 PM
#4
hippyju avatar

hippyju

New Zenner

Join Date:
Jan 2010
Posts:
9
Plugin Contributions:
0

Re: Adding alt text to an image

Hello,
for all the images, especially for the products. I want to optimize the alt texts for the search engines. Most of my images don't have any alt text!!!
Many thanks,
Julie :)

23 May 2010, 9:41 AM
#5
rainmist avatar

rainmist

New Zenner

Join Date:
Jun 2007
Posts:
71
Plugin Contributions:
0

Re: Adding alt text to an image

Any extension to add customized alt for images?

8 Jul 2010, 11:57 PM
#6
generalexotics avatar

generalexotics

New Zenner

Join Date:
Sep 2009
Posts:
17
Plugin Contributions:
0

Re: Adding alt text to an image

I have figured out how to add text to the alt description for images. For example, in my case I wanted it to say “Product for Sale”.

Look in /includes/modules/

Depending on which images you want to do this to, the file(s) to change are category_row.php, product_listing.php, featured_listing.php – I think you get the picture.

Locate this code (or similar) in each file (which will be followed by code describing the image width and height:

<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name'],

I did a search for the name keyword and then found the one that has the image width and height code after it.

Before the last comma, add the following:

. ‘for Sale’

So that your code looks like this:

<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name']. ' for Sale',

Hope this helps a little.

9 Jul 2010, 12:01 AM
#7
generalexotics avatar

generalexotics

New Zenner

Join Date:
Sep 2009
Posts:
17
Plugin Contributions:
0

Re: Adding alt text to an image

I should add to this that if you do it, please do it the right way and create a duplicate of your files in your template folder.

/includes/modules/your_template/

Copy the file into this folder and then edit it.

29 Jul 2010, 4:16 PM
#8
derek53 avatar

derek53

Zen Follower

Join Date:
Jun 2009
Location:
uk
Posts:
111
Plugin Contributions:
0

Re: Adding alt text to an image

generalexotics:

I have figured out how to add text to the alt description for images. For example, in my case I wanted it to say “Product for Sale”.

Look in /includes/modules/

Depending on which images you want to do this to, the file(s) to change are category_row.php, product_listing.php, featured_listing.php – I think you get the picture.

Locate this code (or similar) in each file (which will be followed by code describing the image width and height:

<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name'],

> 
> I did a search for the name keyword and then found the one that has the image width and height code after it. 
> 
> Before the last comma, add the following:  
> 
> ```php
. ‘for Sale’

So that your code looks like this:

<a href="' . zen_href_link(FILENAME_DEFAULT, $cPath_new) . '">' . zen_image(DIR_WS_IMAGES . $categories->fields['categories_image'], $categories->fields['categories_name']. ' for Sale',

> 
> Hope this helps a little.

hi
is this the code that i can change for the images that arrear on the main page ?  I can adjust all other images through admin but cannot change the main page and just noticed this thread


I did a search for the name keyword and then found the one that has the image width and height code after it.
5 Sep 2010, 7:35 PM
#9
Join Date:
Jul 2010
Location:
Findon, UK
Posts:
90
Plugin Contributions:
0

Re: Adding alt text to an image

I want to get rid of "Alt text" all together. Any change you can tell me how ?

Thanks,

Cheers,

Kim
founder PURE Chocolate Truffles

1 Oct 2010, 2:16 PM
#10
coffeebot3000 avatar

coffeebot3000

New Zenner

Join Date:
Mar 2010
Posts:
16
Plugin Contributions:
0

Re: Adding alt text to an image

I played around a bit and found a way to get rid of the alt text, or simply change the text. (If you change the text, though, it will be over a range of images. I don't know how to change it for an individual image).

Ok, in /includes/functions you'll find a file called "html_output.php".

To remove alt text for products with no main image-
around line 196 you'll see this string of text -

/// alt is added to the img tag even if it is null to prevent browsers from outputting
// the image filename as default
    $image = '<img src="' . zen_output_string($src) . '" alt="' . zen_output_string($alt) . '"';

Change
```php
alt="' . zen_output_string($alt) . '"';

to
    ```php
 alt=" "';

You can insert whatever text you like between the quotes as well.

To remove text from a product main image alt-
around line 200 you'll see this string of text -

    if (zen_not_null($alt)) {
      $image .= ' title=" ' . zen_output_string($alt) . ' "';
    }

Again, just change or remove the text inside the quotes -

if (zen_not_null($alt)) {
   $image .= ' title="THIS HAS BEEN CHANGED"';
 }

This seems to be working for me, but please let me know if there are any adverse effects from this.

15 Nov 2010, 3:28 PM
#11
aozhaver avatar

aozhaver

Zen Follower

Join Date:
Sep 2010
Posts:
121
Plugin Contributions:
0

Re: Adding alt text to an image

Hi all,

I don't get what iv'e done wrong.

I got the product title ALT to display on All/New/Specials listings but on the main products listing pages its just blank, there is no ALT at all!:huh:

Any ideas anyone?

You can check my product listing on (No ALT):

https://www.majesticsilver.co.uk/store/index.php?main_page=index&cPath=93

and New Products (has ALT):

https://www.majesticsilver.co.uk/store/index.php?main_page=products_new

Ive checked product_listing.php in modules and all the images also have ['product_name'] so im assuming that would produce the ALT.

Is there another file to check perhaps?