一直都在用Auto-highslide插件,现在顺便集成到主题里面,免去再安装插件的麻烦,如果你也想使用该插件,可以根据教程的提示进行Wordpress插件集成哦~附件下载在文章下面。。。
集成前提篇
请下载底部优化修改的Auto-highslide关键文件,上传到你的主题目录里面,剔除了不需要的PHP文件,优化CSS文件,体积更小,不易产生冲突。
提醒:如果你已经安装了该插件,请进行集成时关闭插件,否则会与本教程操作步骤产生冲突,导致网站显示出现异常。
代码篇
请在 Footer.php
文件中添加:
<?php if(is_single()):?> <link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/highslide/highslide.css" type="text/css" /> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/highslide/highslide.js"></script> <script type="text/javascript"> jQuery(document).ready(function($) { hs.graphicsDir = "<?php bloginfo('template_url'); ?>/highslide/graphics/"; hs.outlineType = "rounded-white"; hs.dimmingOpacity = 0.8; hs.outlineWhileAnimating = true; hs.showCredits = false; hs.captionEval = "this.thumb.alt"; hs.numberPosition = "caption"; hs.align = "center"; hs.transitions = ["expand", "crossfade"]; hs.addSlideshow({ interval: 5000, repeat: true, useControls: true, fixedControls: "fit", overlayOptions: { opacity: 0.75, position: "bottom center", hideOnMouseOut: true } }); }); </script> <?php endif;?>
在主题函数文件functions.php
文件中添加以下代码
add_filter('the_content', 'addhighslideclass_replace'); function addhighslideclass_replace ($content) { global $post; $pattern = "/<a(.*?)href=('|\")([^>]*).(bmp|gif|jpeg|jpg|png)('|\")(.*?)>(.*?)<\/a>/i"; $replacement = '<a$1href=$2$3.$4$5 class="highslide-image" onclick="return hs.expand(this);"$6>$7</a>'; $content = preg_replace($pattern, $replacement, $content); return $content; }
赞赏
除特别注明外,本站所有文章均为LJY IT BLOG原创,转载请注明出处来自https://www.ljy2345.com/2015/06/wordpress%e9%9b%86%e6%88%90auto-highslide%e5%9b%be%e7%89%87%e7%81%af%e7%ae%b1/
Comments | NOTHING