discuz!帖中图片附件添加alt描述的快捷方法
来源:互联网 发布:南昌淘宝摄影工作室 编辑:程序博客网 时间:2024/05/17 19:20
大家都是知道给图片<img>标签添加alt描述对于SEO的重要性,但是作为国内使用范围最广的discuz!论坛程序却默认没有添加alt描述,现在本文介绍一种简单的方法来帮助站长快速设置图片alt属性,方法如下:
打开模板文件:\template\default\forum\discuzcode.htm
找到如下代码(discuz! X3.2大概在257行左右,其他版本请自行搜索):
改成下面的:
修改结果:
1、当图片附件有文字描述的时候调用该描述至alt;
2、当没有文字描述的时候调用帖子标题至alt;
【*】注意以上修改代码时请注意使用代码编辑器,不要再记事本中修改,切记!
打开模板文件:\template\default\forum\discuzcode.htm
找到如下代码(discuz! X3.2大概在257行左右,其他版本请自行搜索):
<!--{if $_G['setting']['thumbstatus'] && $attach['thumb']}--><img{if $attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']} class="attprice"{/if} style="cursor:pointer" id="aimg_$attach[aid]" aid="$attach[aid]" src="{STATICURL}image/common/none.gif" onclick="zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G[setting][showexif]}')" zoomfile="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes¬humb=yes{else}{$attach[url]}$attach[attachment]{/if}" file="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode{else}{$attach[url]}$attachthumb{/if}" inpost="1"{if $_GET['from'] != 'preview'} onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"{/if} /><!--{else}--><img{if $attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']} class="attprice"{/if} id="aimg_$attach[aid]" aid="$attach[aid]" src="{STATICURL}image/common/none.gif" zoomfile="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes¬humb=yes{else}{$attach[url]}$attach[attachment]{/if}" file="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes{else}{$attach[url]}$attach[attachment]{/if}" $widthcode id="aimg_$attach[aid]" inpost="1"{if $_GET['from'] != 'preview'} onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"{/if} /><!--{/if}-->
改成下面的:
<!--{if $_G['setting']['thumbstatus'] && $attach['thumb']}--><img alt="{if $attach['description']}$attach['description']{else}$_G['thread']['subject']{/if}"{if $attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']} class="attprice"{/if} style="cursor:pointer" id="aimg_$attach[aid]" aid="$attach[aid]" src="{STATICURL}image/common/none.gif" onclick="zoom(this, this.getAttribute('zoomfile'), 0, 0, '{$_G[setting][showexif]}')" zoomfile="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes¬humb=yes{else}{$attach[url]}$attach[attachment]{/if}" file="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode{else}{$attach[url]}$attachthumb{/if}" inpost="1"{if $_GET['from'] != 'preview'} onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"{/if} /><!--{else}--><img alt="{if $attach['description']}$attach['description']{else}$_G['thread']['subject']{/if}"{if $attach['price'] && $_G['forum_attachmentdown'] && $_G['uid'] != $attach['uid']} class="attprice"{/if} id="aimg_$attach[aid]" aid="$attach[aid]" src="{STATICURL}image/common/none.gif" zoomfile="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes¬humb=yes{else}{$attach[url]}$attach[attachment]{/if}" file="{if $attach[refcheck]}forum.php?mod=attachment{$is_archive}&aid=$aidencode&noupdate=yes{else}{$attach[url]}$attach[attachment]{/if}" $widthcode id="aimg_$attach[aid]" inpost="1"{if $_GET['from'] != 'preview'} onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"{/if} /><!--{/if}-->
修改结果:
1、当图片附件有文字描述的时候调用该描述至alt;
2、当没有文字描述的时候调用帖子标题至alt;
【*】注意以上修改代码时请注意使用代码编辑器,不要再记事本中修改,切记!
1 0
- discuz!帖中图片附件添加alt描述的快捷方法
- Discuz x3.2 去掉图片附件下载提示的方法
- eclipse中方法的快捷注释键 alt+control+j
- 添加图片附件
- discuz 7论坛防止垃圾贴的简便快捷方法
- idea中get\set方法快捷添加
- ubuntu 添加字体的无敌快捷方法....
- MFC对话框添加快捷的方法
- iOS 添加快捷代码的方法
- DISCUZ后台添加主菜单的方法
- Java mail添加图片附件
- MyEclipse 添加xml文件alt+/快捷提示功能
- discuz后台主导航栏菜单中添加新的菜单项的方法
- discuz后台主导航栏菜单中添加新的菜单项的方法
- discuz后台主导航栏菜单中添加新的菜单项的方法
- 图片alt属性添加方法
- 向Android.mk中添加cpp文件编译快捷方法
- IE8升级新版Flash Player ActiveX14导致的discuz图片附件无法上传 解决方法
- mysql中使用事务和行锁解决并发修改的问题
- Java IO
- 关于Android Studio加载so文件的问题
- 自定义属性的实现
- 基础ANN相关论文研读
- discuz!帖中图片附件添加alt描述的快捷方法
- python3.5安装加密模块pycrypto
- 欢迎使用CSDN-markdown编辑器
- Spring -- 1.IOC,DI,XML
- 四 控制执行流程
- LeetCode 207. Course Schedule
- 第十七章 OAuth2集成——《跟我学Shiro》
- Nginx负载均衡配置说明
- 导致cannot resolve method setSupportActionBar()可能的两种错误