angelx8 Posted July 19, 2015 Share Posted July 19, 2015 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 Quote Link to comment https://forums.phpfreaks.com/topic/297366-add-alt-text-into-page/ Share on other sites More sharing options...
maxxd Posted July 19, 2015 Share Posted July 19, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/297366-add-alt-text-into-page/#findComment-1516780 Share on other sites More sharing options...
scootstah Posted July 19, 2015 Share Posted July 19, 2015 (edited) 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 July 19, 2015 by scootstah Quote Link to comment https://forums.phpfreaks.com/topic/297366-add-alt-text-into-page/#findComment-1516781 Share on other sites More sharing options...
angelx8 Posted July 19, 2015 Author Share Posted July 19, 2015 (edited) 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 July 19, 2015 by angelx8 Quote Link to comment https://forums.phpfreaks.com/topic/297366-add-alt-text-into-page/#findComment-1516786 Share on other sites More sharing options...
angelx8 Posted July 19, 2015 Author Share Posted July 19, 2015 I am uploading my functons.php file if it helpsfunctions.txt Quote Link to comment https://forums.phpfreaks.com/topic/297366-add-alt-text-into-page/#findComment-1516790 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.