立即注册 找回密码

QQ登录

只需一步,快速开始

查看: 3741|回复: 0

[Discuz 通用教程] Discuz 3.2 门户文章如何插入图片自动添加alt标签,利于seo收录

[复制链接]
发表于 2015-8-23 23:59:05 | 显示全部楼层 |阅读模式
道勤网-数据www.daoqin.net

亲注册登录道勤网-可以查看更多帖子内容哦!(包涵精彩图片、文字详情等)请您及时注册登录-www.daoqin.net

您需要 登录 才可以下载或查看,没有账号?立即注册

x

最近道勤小编接了一个小单子;用discuz搭建了个网站——人才招聘网(www.jobbing360.com),用到了门户功能,不得不说Discuz的功能还是非常强大的,但在使用过程中发现在发表文章时添加了图片却不能像wordpress这样自动添加alt标签,经过一番研究,初步解决了这个问题,目前还没有Bug,等待长时间验证,方法如下:

在实施本方法之前请先备份网站数据,以防不测;这次修改需要修改两个文件,分别是:

  1. static/image/editor/editor_function.js
  2. template/default/home/spacecp_blog.htm
复制代码

同时增加一个文件为:

static/image/editor/editor_function.js–复制一份,重命名为:bgeditor_function.js

下面开始修改:editor_function.js

查找代码:

  1. function insertImage(image, url, width, height) {
  2.     url = typeof url == 'undefined' || url === null ? image : url;
  3.     width = typeof width == 'undefined' || width === null ? 0 : parseInt(width);
  4.     height = typeof height == 'undefined' || height === null ? 0 : parseInt(height);
  5.     var html = '<p><a href="' + url + '" target="_blank"><img src="'+image+'"'+(width?' width="'+width+'"':'')+(height?' height="'+height+'"':'')+'></a></p>';
  6.     edit_insert(html);
  7. }
复制代码

修改为

  1. function insertImage(image, url, width, height, subject) {
  2.     url = typeof url == 'undefined' || url === null ? image : url;
  3.     width = typeof width == 'undefined' || width === null ? 0 : parseInt(width);
  4.     height = typeof height == 'undefined' || height === null ? 0 : parseInt(height);
  5.     subject = $('title').value;
  6.     var html = '<p><a href="' + url + '" target="_blank"><img alt="'+subject+'" src="'+image+'"'+(width?' width="'+width+'"':'')+(height?' height="'+height+'"':'')+'></a></p>';
  7.     edit_insert(html);
  8. }
复制代码

再修改刚刚建立的bgeditor_function.js

同样查找代码:

  1. function insertImage(image, url, width, height) {
  2.     url = typeof url == 'undefined' || url === null ? image : url;
  3.     width = typeof width == 'undefined' || width === null ? 0 : parseInt(width);
  4.     height = typeof height == 'undefined' || height === null ? 0 : parseInt(height);
  5.     var html = '<p><a href="' + url + '" target="_blank"><img src="'+image+'"'+(width?' width="'+width+'"':'')+(height?' height="'+height+'"':'')+'></a></p>';
  6.     edit_insert(html);
  7. }
复制代码

修改为:

  1. function insertImage(image, url, width, height, subject) {
  2.     url = typeof url == 'undefined' || url === null ? image : url;
  3.     width = typeof width == 'undefined' || width === null ? 0 : parseInt(width);
  4.     height = typeof height == 'undefined' || height === null ? 0 : parseInt(height);
  5.     var html = '<p><a href="' + url + '" target="_blank"><img alt="'+subject+'" src="'+image+'"'+(width?' width="'+width+'"':'')+(height?' height="'+height+'"':'')+'></a></p>';
  6.     edit_insert(html);
  7. }
复制代码

再编辑:template/default/home/spacecp_blog.htm

查找:editor_function.js

替换为:bgeditor_function.js

编辑完毕保存,把文件上传到原来位置,增加的bgeditor_function.js与editor_function.js一块放在同一目录。后台发布一片文章,输入文章标题,上传图片,进入源代码模式,看看图片是不是有了alt标签?!


道勤主机提供365天*24小时全年全天无休、实时在线、零等待的售后技术支持。竭力为您免费处理您在使用道勤主机过程中所遇到的一切问题! 如果您是道勤主机用户,那么您可以通过QQ【792472177】、售后QQ【59133755】、旺旺【诠释意念】、微信:q792472177免费电话、后台提交工单这些方式联系道勤主机客服! 如果您不是我们的客户也没问题,点击页面最右边的企业QQ在线咨询图标联系我们并购买后,我们为您免费进行无缝搬家服务,让您享受网站零访问延迟的迁移到道勤主机的服务!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

道勤网- 推荐内容!上一条 /2 下一条

!jz_fbzt! !jz_sgzt! !jz_xgzt! 快速回复 !jz_fhlb! !jz_lxwm! !jz_gfqqq!

关于我们|手机版|小黑屋|地图|【道勤网】-www.daoqin.net 软件视频自学教程|免费教程|自学电脑|3D教程|平面教程|影视动画教程|办公教程|机械设计教程|网站设计教程【道勤网】 ( 皖ICP备15000319号-1 )

GMT+8, 2024-9-20 17:52

Powered by DaoQin! X3.4 © 2016-2063 Dao Qin & 道勤科技

快速回复 返回顶部 返回列表