将alt img标签添加到现有的php网站

[英]Adding alt img tags to an existing php website


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.

我目前正在尝试为运行interspire购物车平台的现有网站添加alt img标签,我已经非常接近我了,但我似乎无法做到正确。任何帮助都会受到赞赏。

// 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

我试过发布代码,但它说新用户由于某种原因无法发布图片代码

3 个解决方案

#1


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

在我打开alt属性,然后是文本,然后是另一个结束引用之后,我认为你有两个双引号。

#2


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 . '" />'; 

#3


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

ylebre意思是:(向右滚动代码框)

} 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) . '" />';
}

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2009/06/16/359a79efa476a52507a367f9cd72c3eb.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号