用shopex的朋友都知道,shopex中对商品图片img的处理都是直接用title,而没有alt属性。
那么如何才能给商品图片img加上alt属性呢?
首先登陆ftp,找到/plugins/widgets/goods/文件夹里面default.html文件。打开并找到第23行将代码
<{if $setting.goodsImgHeight}>height="<{$setting.goodsImgHeight}>"<{/if}><{/if}> src="<{$goods_data.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager}>" title="<{$goods_data.name}>"></a></div><{/if}>
<{/capture}>
修改为
<{if $setting.goodsImgHeight}>height="<{$setting.goodsImgHeight}>"<{/if}><{/if}> src="<{$goods_data.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager}>" alt="<{$goods_data.name}>"></a></div><{/if}>
<{/capture}>
如果需要保留原来的title属性,那就改为如下
<{if $setting.goodsImgHeight}>height="<{$setting.goodsImgHeight}>"<{/if}><{/if}> src="<{$goods_data.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager}>" title="<{$goods_data.name}>" alt="<{$goods_data.name}>"></a></div><{/if}>
<{/capture}>
这样就能在商品展示的时候调用alt属性了。