用wordpress写文章,看文章的时候发现图片太小,看不清。我在想,要是图片可以点击放大就好了,于是我在网上找了一些教程,自己测试了一下,终于实现了这种效果。wordpress设置文章图片点击放大,可以增加用户的体验度。
首先安装一个wordpress图片放大插件
插件下载之后,来到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>
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
关注志博公众号,更多干货等着你







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
2020年06月03日 下午12:54 沙发
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
2020年06月03日 下午3:30 1层
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
2021年06月13日 下午11:19 板凳
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
2021年06月26日 下午8:20 地板
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
2021年06月26日 下午8:23 1层
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