WordPress灯箱插件不生效

Reference

https://www.freesion.com/article/24021467976/
https://blog.csdn.net/weixin_41978699/article/details/121091448
https://www.wordpressleaf.com/2017_1955.html

# Markdown图片语法转换后只有img标签,而灯箱插件需要识别a标签
![baidu](https://www.baidu.com/img/bd_logo1.png)
                           ⬇️
<img src="https://www.baidu.com/img/bd_logo1.png" alt="baidu">

Wordpress_Lightbox_Plugin_A-1671770767.png

# 编辑你主题下的header.php,</header>前插入以下代码,'.entry-content img'要换成你自己的CSS类名
vi /usr/local/nginx/html/wordpress/wp-content/themes/flat/header.php
#为img标签嵌套a标签
<script type="text/javascript">
     jQuery(document).ready(function($){
         $('.entry-content img').each(function(i){
              if (! this.parentNode.href) {
                  $(this).wrap("<a href='"+this.src+"'></a>");
              }
          });
     });
</script>

# 重启nginx
systemctl restart nginx

Wordpress_Lightbox_Plugin_B-1671770767.png