{"id":580,"date":"2022-04-12T14:24:59","date_gmt":"2022-04-12T14:24:59","guid":{"rendered":"http:\/\/www.nywzjs.com\/?p=580"},"modified":"2022-04-12T14:36:42","modified_gmt":"2022-04-12T14:36:42","slug":"thinkcmf5-%e8%87%aa%e5%8a%a8%e7%94%9f%e6%88%90%e7%bc%a9%e7%95%a5%e5%9b%be","status":"publish","type":"post","link":"http:\/\/www.nywzjs.com\/?p=580","title":{"rendered":"thinkcmf5 \u81ea\u52a8\u751f\u6210\u7f29\u7565\u56fe"},"content":{"rendered":"\n<p>\u8be5\u65b9\u6cd5\u662f\u4f7f\u7528thinkphp\u6846\u67b6\u81ea\u5e26\u7684\u751f\u6210\u7f29\u7565\u56fe\u65b9\u6cd5\uff0c\u628a\u751f\u6210\u7684\u7f29\u7565\u56fe\u6839\u636e\u5b9a\u4e49\u7684\u5bbd\u9ad8\u5404\u81ea\u5b58\u653e\u3002\u5982\u679c\u5b58\u5728\u76f8\u540c\u5bbd\u9ad8\u3001\u540d\u79f0\u7684\u7f29\u7565\u56fe\uff0c\u5219\u4e0d\u518d\u751f\u6210\u65b0\u7684\u7f29\u7565\u56fe\u3002<\/p>\n\n\n\n<p>1.\u5728public\\upload\\\u91cc\u6dfb\u52a0\u6587\u4ef6\u5939thumbnail\u6765\u5b58\u653e\u7f29\u7565\u56fe\u3002<\/p>\n\n\n\n<p>2.\u5728\\simplewind\\cmf\\common.php \u7684\u6700\u540e\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n*&nbsp;\u751f\u6210\u7f29\u7565\u56fe&nbsp;\uff08\u4e0d\u66ff\u6362\u539f\u56fe\uff09\n*&nbsp;@param&nbsp;$img&nbsp;&nbsp;\u539f\u56fe\u8def\u5f84&nbsp;&nbsp;\u8def\u5f84\u683c\u5f0f:&nbsp;admin\/20180101\/xxxxxxx.png\n*&nbsp;@param&nbsp;int&nbsp;$width&nbsp;&nbsp;\u5bbd\u5ea6\n*&nbsp;@param&nbsp;int&nbsp;$height&nbsp;&nbsp;\u9ad8\u5ea6\n*&nbsp;@return&nbsp;string&nbsp;&nbsp;\u8fd4\u56de\u53ef\u8bbf\u95ee\u7684\u56fe\u7247\u8def\u5f84\n*\/\nfunction thumb( $img, $width=500, $height=500 ) {\n    ini_set('memory_limit', '300M'); \/\/\u9632\u6b62\u5185\u5b58\u6ea2\u51fa\uff08\u5982\u679c\u56fe\u7247\u5206\u8fa8\u7387\u592a\u9ad8\u53ef\u80fd\u51fa\u73b0\u5185\u5b58\u6ea2\u51fa\uff09\n    if (empty($img)) return '';\n    if (strpos($img, \"http\") === 0 || strpos($img, \"\/\/\") === 0 ) return $img;\n    $array = &nbsp;explode( '\/', $img );\n    if ( count( $array ) != &nbsp;3 ) return cmf_get_image_url( $img );\n    $imgName = explode('.', $array&#91;count($array)]); \/\/\u83b7\u53d6\u56fe\u7247\u540d\u79f0\n    if ( !file_exists( \".\/upload\/$img\" ) ) return '';\/\/\u5982\u679c\u539f\u56fe\u5df2\u4e22\u5931\n    $newName = $imgName&#91;0] . \"-$width-$height.\" . $imgName&#91;1];\n    if ( file_exists( \".\/upload\/thumbnail\/$newName\" ) ) {\n        \/\/\u56fe\u7247\u7f29\u7565\u56fe\u5df2\u5b58\u5728\n        return cmf_get_image_url( \"thumbnail\/$width$height-$img_name\" );\n    } else {\n        \/\/\u751f\u6210\u7f29\u7565\u56fe\n        $image = &nbsp;\\think\\Image::open( ROOT_PATH . \"\/public\/upload\/$img\" );\n        $image-&gt;thumb( $width, $height, 1)-&gt;save( \".\/upload\/thumbnail\/$newName\", null, 100 );\n        return cmf_get_image_url( \"\/upload\/thumbnail\/$newName\");\n    }\n}<\/code><\/pre>\n\n\n\n<p>html\u8c03\u7528\u4f8b\u5b50:<strong><span class=\"has-inline-color has-vivid-red-color\"> {:thumb($vo.thumbnail,600,600)}<\/span><\/strong><\/p>\n\n\n\n<p>\u5173\u4e8eThinkPHP\u56fe\u7247\u5904\u7406\u76f8\u5173\u6587\u6863\uff1ahttps:\/\/www.kancloud.cn\/manual\/thinkphp5_1\/354123<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u9700\u8981\u5148\u6267\u884ccomposer require topthink\/think-image\u6765\u5f15\u5165\u6587\u4ef6\u3002<\/p><cite>https:\/\/www.kancloud.cn\/manual\/thinkphp5_1\/354123<\/cite><\/blockquote>\n\n\n\n<p>\u6ce8\u610f\uff1a\u6b64\u65b9\u6cd5\u5e76\u672a\u6838\u5b9e\u6d4b\u8bd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8be5\u65b9\u6cd5\u662f\u4f7f\u7528thinkphp\u6846\u67b6\u81ea\u5e26\u7684\u751f\u6210\u7f29\u7565\u56fe\u65b9\u6cd5\uff0c\u628a\u751f\u6210\u7684\u7f29\u7565\u56fe\u6839\u636e\u5b9a\u4e49\u7684\u5bbd\u9ad8\u5404\u81ea\u5b58\u653e\u3002\u5982\u679c\u5b58\u5728\u76f8\u540c\u5bbd\u9ad8\u3001 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":546,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[45,136,126,137],"_links":{"self":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/posts\/580"}],"collection":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=580"}],"version-history":[{"count":0,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/posts\/580\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=\/wp\/v2\/media\/546"}],"wp:attachment":[{"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nywzjs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}