请选择 进入手机版 | 继续访问电脑版

UESOHO

Discuz!x3.2门户文章图片添加Alt的方法

沸沸队长 发表于 4-15 22:17:47 | 0 条回复 | 635 次浏览

discuz x门户编辑器发布文章的时候都会遇到图片没法设置ALT描述,这样导致文章的内容优化非常不友好
现在分享下Discuz x3.2门户文章图片添加Alt的方法
文件:
static/image/editor/editor_function.js
template/default/home/spacecp_blog.htm
另存: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.         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. } {
复制代码
再编辑:template/default/home/spacecp_blog.htm
查找:
editor_function.js
替换为
bgeditor_function.js

覆盖同名文件,更新缓存,发布文章测试看看
熟悉的歌谣里,藏着童话的影子。

回复 道具 举报

您需要登录后才可以回帖 登录 | 注册

UESOHO/津ICP备11001501号-4 Powered by Discuz!

top