Jump to content

Add ALT Text Into Page


angelx8

Recommended Posts

Hi,

 

I'm using an ecommerce script and want to add an ALT image tag into each product description page. It sounds simple enough, but I can't get it to work. After a whole day of going through the scripts code I have managed to find where the image information is generated, but there is no ALT tag by default in this part of the site for some reason.

 

The image information seems to be generated in the functions.php file and it seems to be this line:

 

$preview="<img src='".$preview_url."' border='0'>";

 

I tried to modifiy it by making it look like this:

 

$preview="<img src='".$preview_url."' border='0'  alt='".$ds->row["title"]."' >";

 

By adding this code (which adds the ALT tag in another part of the site - the related items at the bottom of each product page) I though that the product title which appears at the top of the product page would be used as the ALT text. I tried adding a basic ALT tag (e.g ALT="sample alt tag") and this shows up on the site, so I am quite certain this is the place where the ALT tag could be defined, I just can't get it to generate an ALT tag relevant to each product.

 

The code I tried to add comes from another file where the ALT tag works for the related images section, so I'm not sure if this has something else missing from it.

 

Am I supposed to add anything anywhere else? I'm really stuck on this and have been trying to do it for a whole day, so if anyone can tell me what I am doing wrong, I would really appreciate it! Thanks

Link to comment
Share on other sites

Is $ds defined in the function (or function sheet) you're altering? Check the code on the page you're using as an example - it's probably (I'm assuming you're using WordPress) a global, and you should be able to use it by adding

global $ds;

at the top of the function. However, it's difficult to tell without looking at the code.

Link to comment
Share on other sites

Why do you want to add the page title as the image alt? The alt is supposed to be a textual representation of the image in case it fails to load.

 

You said you just copied code from some other part of the system that worked and tried it here. That's not necessarily going to work. Is $ds defined in this context? Does it contain the right data? What is not working? Are you getting errors?

Edited by scootstah
Link to comment
Share on other sites

Thanks for the fast replies. I'm not actually using Wordpress, its a standalone ecommerce script. I have asked in the official forum, but the developers don't seem to answer questions, even those posted over a month ago from other people so I think I am on my own with this one. When I said it doesn't work before, I meant that no alt tag shows up.

 

I found global $ds; already in the functions file, but not sure what to do with it? Should I add it somewhere else?

 

Would it help if I pasted some parts of the code? If so which parts do I need to paste?

Edited by angelx8
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.