Adding alt img tags to an existing php website

Go To StackoverFlow.com

1

I am currently trying to add in alt img tags for an existing website running the interspire shopping cart platform, I have gotten pretty close I bleieve, but i cannot seem to get it right. Any help would be grealty appreciated.

// Is there a thumbnail image we can show? 
$thumb = $GLOBALS['ISC_CLASS_PRODUCT']->GetThumb(); 
$alttext = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductName(); 

if ($thumb == '' && GetConfig('DefaultProductImage') != '') {
    if (GetConfig('DefaultProductImage') == 'template') {
        $thumb = GetConfig('ShopPath').'/templates/'.GetConfig('template').'/images/ProductDefault.gif'; 
    } else { 
        $thumb = GetConfig('ShopPath').'/'.GetConfig('DefaultProductImage'); 
    } 
    $thumbImage = '<img src="'.$thumb.'" alt="->GetProductName" />'; 
} else if ($thumb != '') { 
    $thumbImage = '<img src="'.GetConfig('ShopPath').'/'.GetConfig('ImageDirectory').'/'.$thumb.'" alt=""'.$alttext.'" />';
}

I have tried posting the code but it says new users cannot post image tags for some reason

2009-06-16 13:56
by NoName
You should be able to place it as a code snippet. Just don't copy and paste it directly. Paste it, highlight it, and look for the icon with 0's and 1's to place it in code tags - Ian Elliott 2009-06-16 14:02
Give me a moment, I'll try it put it in there, you've got to put it in as "code", which means that it's indented four spaces. It is trying to treat your text as HTML - cgp 2009-06-16 14:03
I tried, it would be best if you did it as you have the original formatting. Just follow what Ian said - cgp 2009-06-16 14:06


0

It looks to me like you have two double quotes after you open the alt attribute, then the text, then another closing quote.

2009-06-16 14:23
by ylebre


0

This line won't work

$thumbImage = '<img src="'.$thumb.'" alt="->GetProductName" />'; 

You probably want something like this

$thumbImage = '<img src="'.$thumb.'" alt="'.$GLOBALS['ISC_CLASS_PRODUCT']->GetProductName().'" />'; 

//or as you have already set $alttext:
$thumbImage = '<img src="'.$thumb.'" alt="' . $alttext . '" />'; 
2009-06-16 14:26
by Tom Haigh
I tried both and Im still not getting any alt tags = - NoName 2009-06-16 14:34


0

ylebre meant: (scroll the code box to the right)

} else if($thumb != '') { 
    $thumbImage = '<img src="'.GetConfig('ShopPath').'/'.GetConfig('ImageDirectory').'/'.$thumb.'" alt=""'.$alttext.'" />';
}
                                                                                                        ^
                                                                                                        |

there is one extra " at the end!

} else if($thumb != '') { 
    $thumbImage = '<img src="'.GetConfig('ShopPath').'/'.GetConfig('ImageDirectory').'/'.$thumb.'" alt="' . htmlspecialchars($alttext) . '" />';
}
2009-06-16 14:47
by stefs
I fixed that actually before I posted this and I am still not getting alt tags im not sure whats going on but I think im starting to lose it lo - NoName 2009-06-16 15:03
When you load the site and view the source it still comes back as a blank alt tag like [Code]

alt=" - NoName 2009-06-16 15:45

is there even any content in "$alttext = $GLOBALS['ISCCLASSPRODUCT']->GetProductName();" - stefs 2009-06-16 21:24
There is content in the getproductname, I am honestly just debating paying someone to fix it to get it over with - NoName 2009-06-16 21:45
i can only think of 2 possibilities: 1. $alttext is empty, because "$GLOBALS['ISCCLASSPRODUCT']->GetProductName();" doesn't return the expected value, or 2. the rendering codeblock is not the one drawing the actual images. you can verify both by inserting logging statements. i recommend FirePHP - stefs 2009-06-17 05:39
Ads