如题,
在发布图片的时候,直接复制粘贴的话,是没有一些属性的,即只有img属性没有href属性,就会造成auto-highslide等图片特效插件失效。
所以,在编辑图片的时候,必须要手动地设置图片链接到图像URL,如下图:
百度了一下,找到两种方法,
方法一:知更鸟用JS
参考:http://zmingcx.com/wordpress-pictures-auto-add-links.html
我测试了一下,虽然没成功,但是写下来mark一下。
方法二:自定义function
1 2 3 4 5 6 7 | //图片自动增加超链接到文章,并添加标题和ALT属性 function auto_post_link($content) { global $post; $content = preg_replace('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i', "<a href=\"$2\"title=\"".$post->post_title."\" ><img src=\"$2\ " alt=\"".$post->post_title."\" /></a>", $content); return $content; } add_filter ('the_content', 'auto_post_link',0); |
会员登录关闭
注册会员关闭