Home  >  Article  >  Database  >  Automatically add links to the original images for WordPress article images without modifying the database

Automatically add links to the original images for WordPress article images without modifying the database

巴扎黑
巴扎黑Original
2016-11-07 10:56:101848browse

WordPress日志中插入图片附件显示设置中有四种选择分别是:自定义URL、媒体文件、附件页面和无,一般我们选择第二种链接到媒体文件,只有这样一些图片暗箱放大特效才能启用,但很多童鞋对WP基本功能不是很熟习,插入图片时根本就不知道去选择显示方式,当发现无法启用图片暗箱放大特效后,为时已晚,重新编辑文章不仅工作量大而且很麻烦,这里提供一个补救的方法。

添加下面的JS代码到主题header.php模版文件中:

   

该脚本会检查文章中的图片是否包含了链接,如果没有,会自动为图片添加链接到原图。

修改其中的 .entry 为你主题正文的CSS类。

如果你的主题未加载jquery.js库文件,代码将无效,可以将这句代码加到上面:

1

   


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:mysql database operationNext article:mysql database operation