{"id":645797,"date":"2012-12-03T02:27:07","date_gmt":"2012-12-03T02:27:07","guid":{"rendered":"http:\/\/www.xptt.com\/?p=645797"},"modified":"2014-11-03T21:00:08","modified_gmt":"2014-11-03T13:00:08","slug":"the-wordpress-free-plug-thumbnail-support-outside-the-chain-figure","status":"publish","type":"post","link":"https:\/\/xptt.com\/645797.html","title":{"rendered":"wordpress\u514d\u63d2\u4ef6\u7f29\u7565\u56fe\u652f\u6301\u5916\u94fe\u56fe"},"content":{"rendered":"<p>\u524d\u5929\u5728\u6574\u7f29\u7565\u56fe\uff0c\u4e5f\u8bb8\u6709\u5f88\u591a\u535a\u5ba2\u5199\u6587\u7ae0\u4e0d\u559c\u6b22\u5e26\u56fe\uff0c\u4f46\u662f\u56fe\u6587\u5e76\u8302\uff0c\u770b\u8d77\u6765\u4f1a\u597d\u770b\u4e9b\uff0c\u6240\u4ee5\u672c\u7ad9\u6bcf\u7bc7\u6587\u7ae0\u90fd\u5e26\u4e00\u5f20\u56fe\u7247\uff0c\u5c31\u7b97\u6ca1\u6709\u56fe\uff0c\u4e5f\u8981\u622a\u53d6\u4e00\u5f20\uff0c\u90a3\u4e48\u73b0\u5728\u81ea\u5df1\u6574\u4e3b\u9898\uff0c\u4e0d\u60f3\u7528\u63d2\u4ef6\uff0c\u4e0d\u60f3\u7528\u5e26\u751f\u4ea7\u7f29\u7565\u56fe\u7684\u4ee3\u7801\uff0c\u5c31\u627e\u5230\u4e86\u4e00\u4e2a\u514d\u63d2\u4ef6\u5b9e\u73b0\u7f29\u7565\u56fe\u7684\u529f\u80fd\uff1a<\/p>\n<blockquote><p>&lt;?php<br \/>\nfunction catch_that_image() {<br \/>\nglobal $post, $posts;<br \/>\n$first_img = '';<br \/>\nob_start();<br \/>\nob_end_clean();<br \/>\n$output = preg_match_all('\/&lt;img.+src=[\\'\"]([^\\'\"]+)[\\'\"].*&gt;\/i', $post-&gt;post_content, $matches);<br \/>\n$first_img = $matches [1] [0];<br \/>\nif(empty($first_img)){ \/\/Defines a default image<br \/>\n$first_img = \"\/images\/default.jpg\";}return $first_img;}<\/p>\n<p>?&gt;<\/p><\/blockquote>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5199\u5165functions\u91cc\u9762\u4ee5\u540e\uff0c\u5f53\u6587\u7ae0\u6ca1\u6709\u56fe\u7247\u7684\u65f6\u5019\uff0c\u9ed8\u8ba4\u7f29\u7565\u56fe\u53ea\u80fd\u6307\u5b9a\u4e00\u4e2a\u7edd\u5bf9\u8def\u5f84\uff0c\u90a3\u4e48\u6211\u60f3\u81ea\u52a8\u83b7\u53d6\u4e3b\u9898\u8def\u5f84\uff0c<br \/>\n\u800c\u4e0d\u662fhost\/images\/default.jpg\uff0c\u53e6\u5916\u6211\u60f3\u5b9e\u73b0\u9ed8\u8ba4\u56fe\u7247\u4e3a\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u968f\u673a\u56fe\u7247\uff0c\u800c\u4e0d\u662f\u5168\u90fd\u4e00\u6837\u7684\uff0c\u5e94\u8be5\u5982\u4f55\u5b9e\u73b0\u4e86\uff1f<\/p>\n<p>\u7ecf\u8fc7\u6293\u7834\u5934\u76ae\u7684\u641c\u7d22\u8d44\u6599\uff0c\u624d\u5b9e\u73b0\u4e86\u8fd9\u4e2a\u6548\u679c\uff0c\u8fd9\u5c31\u662f\u4e0d\u61c2\u4ee3\u7801\u7684\u90c1\u95f7\uff0c\u4e0d\u8fc7\u8fd8\u662f\u88ab\u6211\u6574\u51fa\u6765\u4e86\uff1a<\/p>\n<p>\u7f51\u4e0a\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<blockquote><p>&lt;?php<br \/>\nfunction catch_that_image() {<br \/>\n$tu=rand(1,10);<br \/>\nglobal $post, $posts;<br \/>\n$first_img = '';<br \/>\nob_start();<br \/>\nob_end_clean();<br \/>\n$output = preg_match_all('\/&lt;img.+src=[\\'\"]([^\\'\"]+)[\\'\"].*&gt;\/i', $post-&gt;post_content, $matches);<br \/>\n$first_img = bloginfo('template_url').$matches [1] [0];<br \/>\nif ($matches[1][0]=='') {<br \/>\n$first_img = '\/images\/rand\/'.$tu.'.jpg'; \/\/\u5982\u679c\u6587\u7ae0\u6ca1\u6709\u56fe\u7247\u5219\u968f\u673a\u8c03\u7528\u9ed8\u8ba4\u56fe\u7247<br \/>\n}<br \/>\nreturn $first_img;}<\/p>\n<p>?&gt;<\/p><\/blockquote>\n<p>\u5728\u4e3b\u9898\u7684images\u4e0b\u5efa\u7acbrand\u6587\u4ef6\u5939\uff0c\u91cc\u9762\u653e\u540d\u79f0\u4e3a1.jpg,2.jpg...\u523010.jpg\u768410\u5f20\u56fe\u7247\u3002\u3002\u3002<\/p>\n<p>\u7ecf\u8fc7\u6d4b\u8bd5\uff0c\u7136\u540e\u4ed4\u7ec6\u770b\u8fd9\u4e2a\u4ee3\u7801\u6709\u4e2a\u4e25\u91cd\u7684\u95ee\u9898\uff0c\u867d\u7136\u5b9e\u73b0\u4e86\u6211\u8981\u7684\u529f\u80fd\uff0c\u4f46\u662f\u6709\u7f29\u7565\u56fe\u7684\u6587\u7ae0\u5c45\u7136\u65e0\u6cd5\u663e\u793a\u7f29\u7565\u56fe\u4e86\uff0c\u540e\u6765\u7ecf\u8fc7\u6539\u6b63\uff0c\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<blockquote><p>function catch_that_image() {<br \/>\n$tu=rand(1,10);<br \/>\nglobal $post, $posts;<br \/>\n$first_img = '';<br \/>\nob_start();<br \/>\nob_end_clean();<br \/>\n$output = preg_match_all('\/&lt;img.+src=[\\'\"]([^\\'\"]+)[\\'\"].*&gt;\/i', $post-&gt;post_content, $matches);<br \/>\n$first_img = $matches [1] [0];<br \/>\nif(empty($first_img)){ \/\/Defines a default image<br \/>\n$first_img = bloginfo('template_url').\"\/images\/rand\/\".$tu.\".jpg\";}<\/p>\n<p>return $first_img;}<\/p><\/blockquote>\n<p>\u4e0d\u61c2\u4ee3\u7801\uff0c\u53ea\u80fd\u9760\u601d\u8003\u4e86\uff0c\u54c8\u54c8\uff0c\u8fd9\u4e2a\u514d\u63d2\u4ef6\u7f29\u7565\u56fe\u8fd8\u4e0d\u9519\uff0c\u4e4b\u524d\u6709\u8003\u8651\u8fc7\u90a3\u4e2athumbnail\u7684\u90a3\u4e2a\uff0c\u4f46\u662f\u4ee3\u7801\u90a3\u4e48\u591a\uff0c\u800c\u4e14\u8fd8\u6709\u4ec0\u4e48cache\u4e4b\u7c7b\uff0c\u9ebb\u70e6\uff0c\u5360\u7a7a\u95f4\uff0c\u6240\u4ee5\u5c31\u4e0d\u7528\u4e86\uff0c\u73b0\u5728\u8fd9\u4e2a\u7b80\u5355\u591a\u4e86\uff0c\u8f7d\u5165\u4e5f\u4e0d\u4f1a\u6162\uff0c\u6ee1\u5feb\u7684\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u5929\u5728\u6574\u7f29\u7565\u56fe\uff0c\u4e5f\u8bb8\u6709\u5f88\u591a\u535a\u5ba2\u5199\u6587\u7ae0\u4e0d\u559c\u6b22\u5e26\u56fe\uff0c\u4f46\u662f\u56fe\u6587\u5e76\u8302\uff0c\u770b\u8d77\u6765\u4f1a\u597d\u770b\u4e9b\uff0c\u6240\u4ee5\u672c\u7ad9\u6bcf\u7bc7\u6587\u7ae0\u90fd\u5e26\u4e00\u5f20\u56fe\u7247\uff0c\u5c31 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[733,1113,1114],"views":32930,"_links":{"self":[{"href":"https:\/\/xptt.com\/wp-json\/wp\/v2\/posts\/645797"}],"collection":[{"href":"https:\/\/xptt.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xptt.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xptt.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xptt.com\/wp-json\/wp\/v2\/comments?post=645797"}],"version-history":[{"count":0,"href":"https:\/\/xptt.com\/wp-json\/wp\/v2\/posts\/645797\/revisions"}],"wp:attachment":[{"href":"https:\/\/xptt.com\/wp-json\/wp\/v2\/media?parent=645797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xptt.com\/wp-json\/wp\/v2\/categories?post=645797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xptt.com\/wp-json\/wp\/v2\/tags?post=645797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}