
{"id":175,"date":"2021-07-24T00:28:19","date_gmt":"2021-07-23T16:28:19","guid":{"rendered":"http:\/\/dba.qishuo.xin\/?p=175"},"modified":"2023-04-03T09:27:11","modified_gmt":"2023-04-03T01:27:11","slug":"%e5%85%8d%e6%8f%92%e4%bb%b6%e5%ae%9e%e7%8e%b0-wordpress-lightbox-%e7%81%af%e7%ae%b1%e6%95%88%e6%9e%9c","status":"publish","type":"post","link":"http:\/\/dba.qishuo.xin\/?p=175","title":{"rendered":"\u514d\u63d2\u4ef6\u5b9e\u73b0 WordPress LightBox \u706f\u7bb1\u6548\u679c"},"content":{"rendered":"<p>\u7b2c\u4e00\uff1a\u9700\u8981\u5148\u90e8\u7f72\u4e09\u4e2a\u6587\u4ef6\uff0c\u4e24\u4e2a JS \u4e00\u4e2a CSS \u3002\u4e3a\u4e86\u907f\u514d\u62f7\u8d1d\u9519\u8bef\uff0c\u53ef\u4ee5\u76f4\u63a5\u4ece\u6b64\u94fe\u63a5\u4e0b\u8f7d\u6240\u9700\u6587\u4ef6\uff0c\u5305\u62ec\u4ee3\u7801\u90e8\u5206\u3002<br \/>\n<a target=\"_blank\" href=\"http:\/\/knowledge.qishuo.xin\/server\/index.php?s=\/api\/attachment\/visitFile\/sign\/e6d32e9b05cb42cc7b9f87f9e451f9ce\" title=\"[FancyBox-\u89e3\u538b\u5bc6\u7801oneinf.com.zip\">FancyBox-\u89e3\u538b\u5bc6\u7801oneinf.com.zip<\/a><\/p>\n<p>\u4e00\u822c\u60c5\u51b5\u4e0b\u7b2c\u4e00\u4e2a\u6587\u4ef6 jquery-3.2.1.min.js \u4e3b\u9898\u90fd\u4f1a\u5f15\u7528\u6240\u4ee5\u5c31\u4e0d\u9700\u8981\u4e86\u3002 \u4e0b\u9762\u4e24\u4e2a\u662f\u5fc5\u987b\u8981\u7528\u7684\uff0c\u672c\u6587\u4e2d\u662f\u6211\u535a\u5ba2\u7684\u8def\u5f84\uff0c\u8bf7\u6839\u636e\u4f60\u81ea\u5df1\u7684\u8def\u5f84\u8bbe\u7f6e\u6b63\u786e\u7684\u94fe\u63a5\u3002<\/p>\n<pre><code class=\"language-php\">&lt;script src=&quot;http:\/\/www.qishuo.xin\/wordpress\/wp-admin\/css\/jquery-3.2.1.min.js&quot;&gt;&lt;\/script&gt;\n&lt;script src=&quot;http:\/\/www.qishuo.xin\/wordpress\/wp-admin\/css\/jquery.fancybox.min.js&quot;&gt;&lt;\/script&gt;\n&lt;link rel=&quot;stylesheet&quot; href=&quot;http:\/\/www.qishuo.xin\/wordpress\/wp-admin\/css\/jquery.fancybox.min.css&quot; \/&gt;<\/code><\/pre>\n<p>\u7b2c\u4e8c\uff1a\u5c06\u90e8\u7f72\u7684\u6587\u4ef6\u5f15\u5165\u4f60 WordPress \u4e3b\u9898\u5f53\u4e2d header.php \u6587\u4ef6\u7684 <\/head> \u4e4b\u524d\u3002<\/p>\n<p><strong>\u6211\u7684\u4e3b\u9898\u662fbizdir,\u5728\u4e3b\u9898\u76ee\u5f55\u4e2d\u6211\u672a\u627e\u5230header.php\u6587\u4ef6\uff0c\u6211\u6700\u7ec8\u52a0\u5728<code>wp-content\/themes\/customify\/header.php<\/code>\u7684\u6587\u4ef6\u4e2d\u3002<\/strong><\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre><code class=\"language-shell\">vim \/var\/www\/html\/lccdba\/wp-content\/themes\/customify\/header.php<\/code><\/pre>\n<p><a href=\"http:\/\/knowledge.qishuo.xin\/server\/index.php?s=\/api\/attachment\/visitFile\/sign\/b2548934c7c08cb60d3e433c567ac191&amp;showdoc=.jpg\" data-fancybox=\"images\" data-fancybox=\"images\"><img decoding=\"async\" src=\"http:\/\/knowledge.qishuo.xin\/server\/index.php?s=\/api\/attachment\/visitFile\/sign\/b2548934c7c08cb60d3e433c567ac191&amp;showdoc=.jpg\" alt=\"\" \/><\/a><\/p>\n<p>\u7b2c\u4e09\uff1a\u5c06\u4e0b\u9762\u7684\u4ee3\u7801\u653e\u5165\u4f60 WordPress \u4e3b\u9898\u4e0b\u7684 functions.php \u6587\u4ef6\u7684\u7ed3\u5c3e\u5373\u53ef\u5b9e\u73b0\u6548\u679c\u3002<br \/>\n<code>\/var\/www\/html\/lccdba\/wp-content\/themes\/bizdir\/functions.php<\/code><\/p>\n<pre><code class=\"language-php\">\/**FancyBox\u56fe\u7247\u706f\u7bb1**\/\nadd_filter(&#039;the_content&#039;, &#039;fancybox1&#039;);\nadd_filter(&#039;the_content&#039;, &#039;fancybox2&#039;);\nfunction fancybox1($content){\n    global $post;\n    $pattern = &quot;\/&lt;img(.*?)src=(&#039;|\\&quot;)([^&gt;]*).(bmp|gif|jpeg|jpg|png|swf|webp)(&#039;|\\&quot;)(.*?)&gt;\/i&quot;;\n    $replacement = &#039;&lt;a$1href=$2$3.$4$5 data-fancybox=&quot;images&quot;&gt;&lt;img$1src=$2$3.$4$5$6&gt;&lt;\/a&gt;&#039;;\n    $content = preg_replace($pattern, $replacement, $content);\n    return $content;\n}\nfunction fancybox2($content){ \n    global $post;\n    $pattern = &quot;\/&lt;a(.*?)href=(&#039;|\\&quot;)([^&gt;]*).(bmp|gif|jpeg|jpg|png|swf|webp)(&#039;|\\&quot;)(.*?)&gt;(.*?)&lt;\\\/a&gt;\/i&quot;;\n    $replacement = &#039;&lt;a$1href=$2$3.$4$5 data-fancybox=&quot;images&quot;$6&gt;$7&lt;\/a&gt;&#039;;\n    $content = preg_replace($pattern, $replacement, $content);\n    return $content;\n}<\/code><\/pre>\n<p>\u7b2c\u56db\uff1a\u91cd\u65b0\u52a0\u8f7dnginx<\/p>\n<pre><code class=\"language-shell\">\/usr\/sbin\/nginx -c \/etc\/nginx\/nginx.conf -s reload<\/code><\/pre>\n<p>\u6700\u540e\u7684\u6548\u679c\u5982\u4e0b\uff1a<br \/>\n<a target=\"_blank\" href=\"http:\/\/img.oneinf.com\/2019\/04\/FancyBox.png\" data-fancybox=\"images\">http:\/\/img.oneinf.com\/2019\/04\/FancyBox.png<\/a><\/p>\n<p>\u53c2\u8003\uff1a<a target=\"_blank\" href=\"https:\/\/oneinf.com\/tech\/3272.html\">https:\/\/oneinf.com\/tech\/3272.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b2c\u4e00\uff1a\u9700\u8981\u5148\u90e8\u7f72\u4e09\u4e2a\u6587\u4ef6\uff0c\u4e24\u4e2a JS \u4e00\u4e2a CSS&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[8,9],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-wordpress","tag-9"],"_links":{"self":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=175"}],"version-history":[{"count":5,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":2988,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=\/wp\/v2\/posts\/175\/revisions\/2988"}],"wp:attachment":[{"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dba.qishuo.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}