{"id":39,"date":"2025-04-26T11:06:42","date_gmt":"2025-04-26T03:06:42","guid":{"rendered":"http:\/\/blog.fennubird.cn\/?p=39"},"modified":"2025-04-26T11:06:42","modified_gmt":"2025-04-26T03:06:42","slug":"%e6%80%8e%e4%b9%88%e4%b8%8a%e4%bc%a0svg%e5%88%b0wordpress","status":"publish","type":"post","link":"https:\/\/fennubird.cn\/index.php\/2025\/04\/26\/%e6%80%8e%e4%b9%88%e4%b8%8a%e4%bc%a0svg%e5%88%b0wordpress\/","title":{"rendered":"\u600e\u4e48\u4e0a\u4f20SVG\u5230WordPress"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4f17\u6240\u5468\u77e5\uff0cWP\u5929\u751f\u4e0d\u652f\u6301SVG\u6587\u4ef6\u4e0a\u4f20\uff0c\u5c1d\u8bd5\u4e0a\u4f20SVG\u4f60\u4f1a\u770b\u5230\u5982\u4e0b\u9519\u8bef<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"164\" src=\"http:\/\/blog.fennubird.cn\/wp-content\/uploads\/2025\/04\/wordpress-svg-error.webp\" alt=\"\" class=\"wp-image-40\" srcset=\"https:\/\/fennubird.cn\/wp-content\/uploads\/2025\/04\/wordpress-svg-error.webp 1024w, https:\/\/fennubird.cn\/wp-content\/uploads\/2025\/04\/wordpress-svg-error-300x48.webp 300w, https:\/\/fennubird.cn\/wp-content\/uploads\/2025\/04\/wordpress-svg-error-768x123.webp 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6211\u4eec\u600e\u4e48\u89e3\u51b3\u5462\uff1f \u4e24\u79cd\u65b9\u6cd5\uff0c\u4e00\u79cd\u4e0b\u8f7d\u63d2\u4ef6\u5982 <a href=\"https:\/\/wordpress.org\/plugins\/svg-support\/\">SVG Support<\/a>\uff0c\u53e6\u4e00\u79cd\u5229\u7528WP\u63d0\u4f9b\u7684\u94a9\u5b50<strong>upload_mimes<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u8fdb\u5230Panel\u6216\u8005\u5176\u4ed6\u6587\u4ef6\u7f16\u8f91\u5668&nbsp;wp\u6839\u76ee\u5f55-&gt; \u6587\u4ef6\u7ba1\u7406.<\/li>\n\n\n\n<li>\u7f16\u8f91 wp-includes\/<strong>functions.php<\/strong>\u6587\u4ef6<\/li>\n<\/ul>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#f6f6f4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#282A36\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"function add_file_types_to_uploads($file_types){\n  $new_filetypes = array();\n  $new_filetypes['svg'] = 'image\/svg+xml';\n  $file_types = array_merge($file_types, $new_filetypes );\n  return $file_types;\n}\nadd_filter('upload_mimes', 'add_file_types_to_uploads');\" style=\"color:#f6f6f4;display:none\" aria-label=\"\u590d\u5236\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M4.5 12.75l6 6 9-13.5\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M16.5 8.25V6a2.25 2.25 0 00-2.25-2.25H6A2.25 2.25 0 003.75 6v8.25A2.25 2.25 0 006 16.5h2.25m8.25-8.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-7.5A2.25 2.25 0 018.25 18v-1.5m8.25-8.25h-6a2.25 2.25 0 00-2.25 2.25v6\"><\/path><\/svg><\/span><pre class=\"shiki dracula-soft\" style=\"background-color: #282A36\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F286C4\">function<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #62E884\">add_file_types_to_uploads<\/span><span style=\"color: #F6F6F4\">($file_types){<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  $new_filetypes <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1\">array<\/span><span style=\"color: #F6F6F4\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  $new_filetypes[<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">svg<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\">] <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">image\/svg+xml<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  $file_types <\/span><span style=\"color: #F286C4\">=<\/span><span style=\"color: #F6F6F4\"> <\/span><span style=\"color: #97E1F1\">array_merge<\/span><span style=\"color: #F6F6F4\">($file_types,<\/span><span style=\"color: #62E884\"> <\/span><span style=\"color: #F6F6F4\">$new_filetypes<\/span><span style=\"color: #62E884\"> <\/span><span style=\"color: #F6F6F4\">);<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">  <\/span><span style=\"color: #F286C4\">return<\/span><span style=\"color: #F6F6F4\"> $file_types;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F6F6F4\">}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #62E884\">add_filter<\/span><span style=\"color: #F6F6F4\">(<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">upload_mimes<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\">,<\/span><span style=\"color: #62E884\"> <\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #E7EE98\">add_file_types_to_uploads<\/span><span style=\"color: #DEE492\">&#39;<\/span><span style=\"color: #F6F6F4\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u628a\u4e0a\u9762\u7684\u4ee3\u7801\u7c98\u8d34\u5230\u6587\u4ef6\u6700\u540e\u4e00\u884c\uff0c\u5237\u65b0\u540e\u53f0\u5c31\u53ef\u4ee5\u4e0a\u4f20\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f17\u6240\u5468\u77e5\uff0cWP\u5929\u751f\u4e0d\u652f\u6301SVG\u6587\u4ef6\u4e0a\u4f20\uff0c\u5c1d\u8bd5\u4e0a\u4f20SVG\u4f60\u4f1a\u770b\u5230\u5982\u4e0b\u9519\u8bef \u6211\u4eec\u600e\u4e48\u89e3\u51b3\u5462\uff1f \u4e24\u79cd\u65b9\u6cd5\uff0c\u4e00\u79cd\u4e0b\u8f7d\u63d2 &#8230; <a title=\"\u600e\u4e48\u4e0a\u4f20SVG\u5230WordPress\" class=\"read-more\" href=\"https:\/\/fennubird.cn\/index.php\/2025\/04\/26\/%e6%80%8e%e4%b9%88%e4%b8%8a%e4%bc%a0svg%e5%88%b0wordpress\/\" aria-label=\"\u9605\u8bfb \u600e\u4e48\u4e0a\u4f20SVG\u5230WordPress\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":36,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,5],"tags":[],"class_list":["post-39","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","category-5"],"_links":{"self":[{"href":"https:\/\/fennubird.cn\/index.php\/wp-json\/wp\/v2\/posts\/39","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fennubird.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fennubird.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fennubird.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fennubird.cn\/index.php\/wp-json\/wp\/v2\/comments?post=39"}],"version-history":[{"count":0,"href":"https:\/\/fennubird.cn\/index.php\/wp-json\/wp\/v2\/posts\/39\/revisions"}],"wp:attachment":[{"href":"https:\/\/fennubird.cn\/index.php\/wp-json\/wp\/v2\/media?parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fennubird.cn\/index.php\/wp-json\/wp\/v2\/categories?post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fennubird.cn\/index.php\/wp-json\/wp\/v2\/tags?post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}