Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Dec 2004
    Posts
    104
    Plugin Contributions
    0

    Default Change image alt to use product description instead of title in product listings?

    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_p roducts->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.

  2. #2

    Default Adding alt text to an image

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

  3. #3
    Join Date
    Jun 2003
    Posts
    33,715
    Plugin Contributions
    0

    Default Re: Adding alt text to an image

    Which images specifically? Most are created automagically.
    Please do not PM for support issues: a private solution doesn't benefit the community.

    Be careful with unsolicited advice via email or PM - Make sure the person you are talking to is a reliable source.

  4. #4

    Default 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 :)

  5. #5
    Join Date
    Jun 2007
    Posts
    71
    Plugin Contributions
    0

    Default Re: Change image alt to use product description instead of title in product listings?

    Any extension to add customized alt for images?
    LED flood Lights - Energy saving! Eco-friendly! Long lifespan.
    Bollard Lights - Excelllent design.

  6. #6
    Join Date
    Sep 2009
    Posts
    16
    Plugin Contributions
    0

    Default 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:

    PHP Code:
    <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 Code:
    ‘for Sale’ 
    So that your code looks like this:

    PHP Code:
    <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.
    Eric
    www.GeneralExotics.com - Quality Exotic Pets delivered straight to your door!

  7. #7
    Join Date
    Sep 2009
    Posts
    16
    Plugin Contributions
    0

    Default 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.
    Eric
    www.GeneralExotics.com - Quality Exotic Pets delivered straight to your door!

  8. #8
    Join Date
    Jun 2009
    Location
    uk
    Posts
    111
    Plugin Contributions
    0

    Default Re: Adding alt text to an image

    Quote Originally Posted by generalexotics View Post
    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:

    PHP Code:
    <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 Code:
    ‘for Sale’ 
    So that your code looks like this:

    PHP Code:
    <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.
    Thanks to those that offer help

    http://www.shoeshop-uk.com

  9. #9
    Join Date
    Jul 2010
    Location
    Findon, UK
    Posts
    90
    Plugin Contributions
    0

    Default 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

  10. #10
    Join Date
    Mar 2010
    Posts
    16
    Plugin Contributions
    0

    Default 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 -
    PHP Code:
    /// 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 Code:
    alt="' . zen_output_string($alt) . '"'; 
    to
    PHP Code:
     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 -
    PHP Code:
        if (zen_not_null($alt)) {
          
    $image .= ' title=" ' zen_output_string($alt) . ' "';
        } 
    Again, just change or remove the text inside the quotes -
    PHP Code:
     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.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Image ALT text
    By Zeezmom in forum General Questions
    Replies: 5
    Last Post: 28 Apr 2010, 09:28 PM
  2. Adding ALT tag to image in header
    By bhensarl in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 14 Feb 2010, 06:15 AM
  3. Attribute Image Alt/Title Text
    By ibezenned in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 8 Jun 2009, 03:31 PM
  4. Alt text for image
    By res in forum General Questions
    Replies: 4
    Last Post: 14 Jul 2008, 01:20 AM
  5. Adding Alt Text
    By KADesign in forum General Questions
    Replies: 0
    Last Post: 21 Apr 2007, 01:44 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR