谈经验 – 在WordPress上传SVG格式图片

  SVG(Scalable Vector Graphics)是基于可扩展标记语言的可缩放矢量图,矢量图与我们平时接触使用最多的JPEG、GIF、BMP等位图图像最根本的区别就在于可以无限放大并且不损失图像质量。在网页中使用SVG格式最大的好处就是网页被缩放时不会影响到图像质量,在这里就不过多赘述,感兴趣的朋友请自己去搜索了解。

位图与矢量图在放大后的不同如下图所示
谈经验 - 在WordPress上传SVG格式图片

  要在WordPress后台里上传SVG格式图片,首先我们就得获取SVG文件上传的权限,当然如果您直接用FTP上传调用也是可以的。获取权限的方法也很简单,只需要在wp-includes/functions.php文件里找到 // Image formats. 并在下边添加 ‘svg’ => ‘image/svg’, 便可。修改细节如下图所示
谈经验 - 在WordPress上传SVG格式图片

  至于SVG文件您可以用很多软件生成,根据您设计时采用的文件格式选择就好,这里就不一一讲解了。但我还是推荐用Adobe Illustrator,一开始我用的是CorelDRAW生成的,但发现了一些小问题,生成后的图像有时会与原图有少量偏差。本站的Logo文件已更换为SVG格式(http://www.stumblingblock.cn/wp-content/uploads/2017/12/logo.svg),感兴趣的同学们可以自己先看一下效果,如果有生成过程中遇上麻烦的同学再私下找我好了!

谈经验 - 在WordPress上传SVG格式图片

  以下是SVG文件的编码,用任何一种文本编辑器均可做调整。示例用的依然就是我的LOGO文件,在这里可以通过.fil0及.fil1的参数调整很轻易的改变色彩。当然想改变图形也是可以的,同学们自己慢慢折腾研究~

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Creator: CorelDRAW X6 -->
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" width="90mm" height="26mm" version="1.1" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd"
viewBox="0 0 9000 2600"
 xmlns:xlink="http://www.w3.org/1999/xlink">
 <defs>
 <style type="text/css">
 <![CDATA[
 .fil0 {fill:#000000}
 .fil1 {fill:#F4691D;fill-rule:nonzero}
 ]]>
 </style>
 </defs>
 <g id="图层_x0020_1">
 <metadata id="CorelCorpID_0Corel-Layer"/>
 <path class="fil0" d="M586 1167c230,-30 293,227 263,538 -30,312 -157,548 -301,600 -143,52 -410,-295 -410,-632 0,-338 217,-476 448,-506zm199 954c55,-144 224,-100 396,16 172,115 270,264 255,363 -15,100 -301,147 -497,41 -197,-106 -210,-276 -155,-419zm610 144c-90,-161 81,-282 319,-352 238,-70 450,-45 530,45 80,90 -97,389 -345,488 -249,99 -415,-20 -504,-181zm539 -526c-117,-108 -10,-253 167,-374 176,-121 356,-158 446,-106 90,52 25,344 -151,492 -177,148 -345,95 -461,-12zm-436 -1515c43,136 -106,202 -298,217 -192,15 -349,-37 -396,-118 -47,-81 135,-280 339,-316 205,-36 312,80 354,217zm761 973c-171,157 -370,-16 -526,-288 -156,-272 -188,-538 -101,-663 87,-125 505,4 700,280 195,276 98,514 -74,671zm-1247 739c-103,-95 -9,-224 147,-331 156,-107 315,-140 395,-94 80,46 23,304 -134,435 -156,131 -305,84 -408,-11zm646 -432c-114,28 -159,-97 -162,-254 -3,-158 48,-283 117,-317 69,-34 222,124 241,293 19,169 -82,250 -195,278zm-615 -67c-190,-6 -208,-221 -144,-470 64,-249 198,-424 321,-447 123,-23 294,291 251,565 -43,273 -237,358 -427,352zm-254 -1032c71,99 -33,192 -184,255 -152,63 -293,63 -352,9 -59,-54 35,-263 191,-346 156,-83 274,-17 345,82zm-371 377c118,52 75,192 -29,331 -103,140 -232,216 -314,200 -83,-16 -111,-257 -15,-418 96,-161 239,-165 358,-113zm467 -75c74,58 18,149 -81,229 -98,80 -203,111 -259,84 -56,-27 -32,-202 66,-298 97,-96 199,-73 273,-15zm1776 1152l6199 0c77,0 140,63 140,140l0 463c0,77 -63,140 -140,140l-6199 0c-77,0 -140,-63 -140,-140l0 -463c0,-77 63,-140 140,-140zm48 486c35,29 74,43 118,43 25,0 44,-4 56,-13 13,-9 19,-20 19,-33 0,-12 -5,-23 -15,-33 -10,-10 -36,-24 -79,-42 -67,-28 -100,-70 -100,-124 0,-40 15,-71 45,-93 30,-22 70,-33 120,-33 42,0 77,5 105,16l0 86c-29,-20 -62,-29 -101,-29 -23,0 -40,4 -54,12 -13,8 -20,19 -20,33 0,11 5,21 14,30 9,9 32,22 68,38 43,18 72,38 88,58 16,20 24,44 24,72 0,41 -15,72 -44,94 -29,22 -71,32 -124,32 -49,0 -89,-8 -121,-24l0 -92zm549 104c-13,7 -34,11 -61,11 -65,0 -97,-34 -97,-102l0 -144 -50 0 0 -67 50 0 0 -67 89 -25 0 93 70 0 0 67 -70 0 0 129c0,33 13,49 39,49 10,0 20,-3 31,-9l0 67zm374 4l-89 0 0 -47 -1 0c-23,36 -54,54 -94,54 -71,0 -107,-43 -107,-129l0 -184 89 0 0 176c0,46 18,69 54,69 18,0 32,-6 43,-19 11,-12 16,-29 16,-51l0 -175 89 0 0 306zm595 0l-89 0 0 -174c0,-47 -17,-70 -51,-70 -16,0 -29,7 -40,21 -10,14 -16,32 -16,52l0 171 -89 0 0 -177c0,-45 -17,-68 -51,-68 -17,0 -30,7 -40,20 -10,14 -15,31 -15,54l0 171 -89 0 0 -306 89 0 0 48 1 0c11,-18 25,-31 43,-41 18,-10 36,-14 56,-14 43,0 72,19 88,58 24,-39 58,-58 103,-58 67,0 100,41 100,123l0 190zm199 -37l0 37 -89 0 0 -453 89 0 0 194 1 0c23,-36 57,-54 100,-54 39,0 69,13 91,40 22,27 33,64 33,111 0,51 -13,92 -38,122 -25,31 -58,46 -100,46 -38,0 -67,-15 -86,-44l-1 0zm-1 -95c0,20 6,37 18,51 12,14 27,20 46,20 22,0 40,-9 52,-26 12,-17 19,-42 19,-74 0,-26 -6,-47 -17,-62 -11,-15 -28,-22 -49,-22 -20,0 -36,7 -49,22 -13,15 -20,34 -20,57l0 33zm322 132l0 -453 89 0 0 453 -89 0zm195 -404c0,-14 5,-25 15,-33 10,-9 22,-13 37,-13 15,0 28,4 38,13 10,9 14,20 14,33 0,13 -5,25 -15,34 -10,9 -22,13 -37,13 -15,0 -27,-5 -37,-14 -10,-9 -15,-20 -15,-33zm7 404l0 -306 89 0 0 306 -89 0zm493 0l-89 0 0 -171c0,-49 -18,-74 -53,-74 -17,0 -31,7 -42,20 -11,13 -17,30 -17,50l0 174 -89 0 0 -306 89 0 0 49 1 0c22,-37 55,-56 98,-56 68,0 102,42 102,126l0 187zm406 -34c0,57 -16,100 -49,131 -32,31 -79,46 -140,46 -41,0 -74,-6 -98,-18l0 -76c32,18 64,28 96,28 32,0 57,-9 75,-26 18,-17 27,-41 27,-71l0 -25 -1 0c-22,35 -54,52 -96,52 -39,0 -69,-14 -93,-41 -23,-27 -35,-64 -35,-110 0,-51 13,-92 38,-123 26,-31 59,-46 101,-46 38,0 66,15 85,44l1 0 0 -36 89 0 0 272zm-88 -139c0,-20 -6,-37 -18,-51 -12,-14 -28,-21 -46,-21 -22,0 -39,9 -52,26 -13,17 -19,41 -19,72 0,27 6,48 18,63 12,15 28,23 48,23 20,0 37,-8 50,-24 13,-16 19,-36 19,-61l0 -27zm211 172l0 -428 152 0c47,0 83,9 108,27 25,18 38,42 38,74 0,23 -8,44 -24,61 -16,17 -35,30 -59,36l0 1c30,4 54,15 72,33 18,18 27,42 27,69 0,39 -14,70 -41,93 -28,23 -65,34 -113,34l-160 0zm91 -360l0 106 43 0c21,0 37,-5 49,-15 12,-10 18,-24 18,-42 0,-33 -24,-49 -72,-49l-39 0zm0 175l0 117 54 0c23,0 41,-5 54,-16 13,-11 20,-25 20,-44 0,-18 -7,-32 -19,-42 -13,-10 -31,-15 -55,-15l-53 0zm319 186l0 -453 89 0 0 453 -89 0zm184 -151c0,-50 15,-90 45,-119 30,-29 71,-43 122,-43 49,0 88,14 117,42 29,28 43,66 43,114 0,50 -15,90 -45,120 -30,30 -70,45 -121,45 -50,0 -89,-14 -118,-43 -29,-28 -44,-67 -44,-116zm90 -1c0,61 25,92 75,92 48,0 72,-31 72,-94 0,-60 -24,-90 -72,-90 -23,0 -42,8 -55,24 -13,16 -20,39 -20,68zm563 141c-21,13 -52,19 -91,19 -47,0 -84,-14 -113,-43 -29,-28 -43,-65 -43,-110 0,-52 15,-93 46,-123 31,-30 72,-45 124,-45 35,0 61,5 77,14l0 77c-20,-15 -43,-22 -67,-22 -27,0 -49,8 -66,25 -17,17 -25,39 -25,68 0,28 8,50 24,66 16,16 37,24 64,24 24,0 47,-8 70,-23l0 72zm398 11l-108 0 -102 -151 -1 0 0 151 -89 0 0 -453 89 0 0 288 1 0 95 -141 106 0 -113 144 122 161zm63 -82c31,19 61,28 90,28 37,0 55,-10 55,-30 0,-14 -15,-26 -46,-35 -38,-12 -64,-25 -78,-39 -14,-15 -21,-34 -21,-59 0,-30 12,-54 36,-71 24,-17 56,-26 96,-26 28,0 55,4 81,12l0 70c-24,-14 -50,-21 -79,-21 -14,0 -26,3 -34,8 -9,5 -13,12 -13,20 0,14 13,25 39,34 28,9 48,18 62,25 14,8 25,17 32,30 7,12 11,27 11,43 0,32 -13,56 -38,73 -25,17 -59,26 -101,26 -33,0 -64,-5 -92,-16l0 -74zm308 42c0,-14 5,-25 16,-34 10,-9 23,-13 38,-13 15,0 27,5 37,14 10,9 15,20 15,34 0,14 -5,26 -15,34 -10,9 -23,13 -38,13 -14,0 -27,-5 -37,-14 -10,-9 -15,-20 -15,-34zm438 29c-21,13 -52,19 -91,19 -47,0 -84,-14 -113,-43 -29,-28 -43,-65 -43,-110 0,-52 15,-93 46,-123 31,-30 72,-45 124,-45 35,0 61,5 77,14l0 77c-20,-15 -43,-22 -67,-22 -27,0 -49,8 -66,25 -17,17 -25,39 -25,68 0,28 8,50 24,66 16,16 37,24 64,24 24,0 47,-8 70,-23l0 72zm388 11l-89 0 0 -171c0,-49 -18,-74 -53,-74 -17,0 -31,7 -42,20 -11,13 -17,30 -17,50l0 174 -89 0 0 -306 89 0 0 49 1 0c22,-37 55,-56 98,-56 68,0 102,42 102,126l0 187zm-2332 -945c0,-20 7,-38 21,-51 14,-14 31,-21 52,-21 21,0 39,7 53,21 14,14 21,31 21,51 0,20 -7,37 -21,51 -14,14 -32,21 -53,21 -21,0 -38,-7 -52,-21 -14,-14 -21,-31 -21,-51zm307 -662l436 0 0 -247 98 0 0 247 441 0 0 517 -93 0 0 -61 -348 0 0 422 -98 0 0 -422 -343 0 0 61 -93 0 0 -517zm882 84l-348 0 0 288 348 0 0 -288zm-789 288l343 0 0 -288 -343 0 0 288zm1126 -558l992 0 0 1057 -87 0 0 -57 -817 0 0 58 -87 0 0 -1059zm904 80l-817 0 0 840 817 0 0 -840zm-765 643l313 0 0 -224 -273 0 0 -77 273 0 0 -152 -295 0 0 -77 676 0 0 77 -297 0 0 152 274 0 0 77 -274 0 0 224 315 0 0 77 -712 0 0 -77zm456 -152l63 -48c42,43 77,84 107,121l-67 51c-36,-49 -71,-91 -103,-125z"/>
 <path class="fil1" d="M3220 1312l281 0 0 -153 -252 0 0 -141 252 0 0 -411 151 0 0 411 254 0 0 141 -254 0 0 153 282 0 0 143 -282 0 0 265 -151 0 0 -265 -281 0 0 -143zm-186 -78c32,-3 90,-10 175,-20 -8,48 -12,94 -11,137 -132,12 -242,28 -332,48l-36 -128c48,-45 100,-108 154,-191 -58,4 -103,9 -133,15l-51 -129c67,-83 136,-206 205,-370l146 53c-59,111 -120,212 -183,304 21,0 52,-1 95,-3 23,-42 48,-88 74,-136l136 68c-88,144 -168,261 -239,352zm-197 417l-26 -155c100,-14 233,-37 397,-70 -5,26 -9,76 -13,152 -39,8 -158,32 -358,74zm969 -968l129 52c-31,74 -69,154 -114,240l-125 -54c45,-82 81,-161 110,-238zm-447 14c35,79 66,157 94,233l-135 50c-26,-79 -55,-158 -88,-235l129 -49zm1072 363l110 0 0 -137 -94 0 0 -128 94 0 0 -187 131 0 0 187 89 0 0 128 -89 0 0 137 102 0 0 128 -115 0 -25 74 60 -21 102 250 0 -819 325 0 0 798c0,36 -6,64 -19,83 -12,20 -29,31 -50,34 -21,3 -54,6 -98,8 -6,-26 -16,-62 -31,-106l0 233 -128 0 0 -114 -70 28 -16 -48c-124,12 -211,24 -263,38l-40 -90 0 42c0,35 -6,63 -19,83 -13,20 -32,33 -58,37 -26,5 -63,7 -111,5 -8,-40 -17,-85 -28,-132 -14,54 -33,104 -59,152 -26,-35 -58,-74 -94,-117 28,-69 45,-143 52,-221 7,-78 10,-198 9,-361l0 -375 308 0 0 836c42,-65 82,-164 121,-297l-99 0 0 -128zm-144 -267l-66 0 0 155 66 0 0 -155zm676 658c21,0 32,-17 32,-50l0 -591 -69 0 0 640 37 0zm-742 -229l67 0 0 -141 -66 0c0,24 0,71 -1,141zm328 263l124 -7c-19,-53 -38,-105 -58,-156 -22,59 -44,114 -66,163zm-331 -129c-3,96 -10,163 -21,201 29,2 47,3 54,3 25,0 37,-18 37,-53l0 -151 -70 0zm1285 363l0 -428c-40,42 -82,81 -127,120 -26,-60 -53,-118 -82,-172 143,-109 253,-246 330,-410l-303 0 0 -152 1054 0 0 152 -566 0c-34,77 -73,150 -117,220l601 0 0 669 -161 0 0 -70 -469 0 0 73 -161 0zm630 -521l-469 0 0 299 469 0 0 -299z"/>
 </g>
</svg>

发表评论

电子邮件地址不会被公开。 必填项已用*标注