WordPress文章中图片怎么设置点击放大

用wordpress写文章,看文章的时候发现图片太小,看不清。我在想,要是图片可以点击放大就好了,于是我在网上找了一些教程,自己测试了一下,终于实现了这种效果。wordpress设置文章图片点击放大,可以增加用户的体验度。

 

首先安装一个wordpress图片放大插件

插件下载:http://pan.baidu.com/s/1c1QiNIS

插件下载之后,来到wordpress后台,点击“插件”——“安装插件”——“上传插件”,把下载的插件压缩包上传上去进行安装。

插件安装好之后,还要做一些设置,否则效果不能显示出来。找到wp-content/themes/你的主题目录/header.php,在</head>之前加上下面的代码:

 

<script type="text/javascript">
jQuery(document).ready(function($){
 
$('.entry-content img,.entry-featured img').each(function(i){
if (! this.parentNode.href) {
$(this).wrap("<a href='"+this.src+"' class='highslide-image' onclick='return hs.expand(this);'></a>");
}
});
});
</script>

 

加上上面的代码后保存,然后上传到当前主题目录下覆盖即可。

 

这样就设置好了,文章图片点击放大效果就做好了。

 

志博日记是一个专注分享互联网技术的博客,博客网址:www.zhiboblog.com

如果有什么不懂的,可以联系志博的QQ:1662866246

 

关注志博公众号,更多干货等着你
QR: <?php the_title(); ?>
  • 5
  • 12,676 views
    A+
发布日期:2017年11月23日  所属分类:wordpress

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:5   其中:访客  3   博主  2


    Warning: A non-numeric value encountered in /www/wwwroot/www.zhiboblog.com/wp-content/themes/begin2.0/inc/function/comment-template.php on line 20
  1. BitHachi 0

    Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /www/wwwroot/www.zhiboblog.com/wp-content/themes/begin2.0/inc/function/default.php on line 566
    • 志博

      Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /www/wwwroot/www.zhiboblog.com/wp-content/themes/begin2.0/inc/function/default.php on line 566

      @BitHachi

  2. hello 0

    Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /www/wwwroot/www.zhiboblog.com/wp-content/themes/begin2.0/inc/function/default.php on line 566
  3. ASH 0

    Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /www/wwwroot/www.zhiboblog.com/wp-content/themes/begin2.0/inc/function/default.php on line 566
    • 志博

      Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /www/wwwroot/www.zhiboblog.com/wp-content/themes/begin2.0/inc/function/default.php on line 566

      @ASH