{"id":31,"date":"2016-10-28T14:20:50","date_gmt":"2016-10-28T05:20:50","guid":{"rendered":"http:\/\/appw.jp\/2016\/?p=31"},"modified":"2016-10-29T15:04:15","modified_gmt":"2016-10-29T06:04:15","slug":"wordpress-shortcode-%e3%82%92-svg-fallbacks-%e3%81%a7%e8%a9%a6%e3%81%97%e3%81%be%e3%81%99","status":"publish","type":"post","link":"https:\/\/appw.jp\/2016\/?p=31","title":{"rendered":"WordPress Shortcode \u3092 SVG Fallbacks \u3067\u8a66\u3057\u307e\u3059"},"content":{"rendered":"<p>\u5c11\u3057\u53e4\u3044\u30d0\u30fc\u30b8\u30e7\u30f3\u306e\u30d6\u30e9\u30a6\u30b6\u3067\u306f\u3001SVG \u306b\u5bfe\u5fdc\u3057\u306a\u3044\u3082\u306e\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u3088\u3046\u306a\u30d6\u30e9\u30a6\u30b6\u3067\u306f\u3001PNG \u3084 JPEG \u306a\u3069\u306e\u4ee3\u66ff\u753b\u50cf\u30a4\u30e1\u30fc\u30b8\u3092\u8868\u793a\u3055\u305b\u308b\u65b9\u6cd5\u304c\u3068\u3089\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u308c\u304c SVG Fallbacks \u306e\u4ee3\u8868\u4f8b\u306e\u3072\u3068\u3064\u3067\u3059\u3002<\/p>\n<p>\u69d8\u3005\u306a\u65b9\u6cd5\u304c\u767a\u898b\u3055\u308c\u305f\u308a\u3001\u958b\u767a\u3055\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u30a4\u30f3\u30e9\u30a4\u30f3 SVG \u3092\u5229\u7528\u3057\u305f\u65b9\u6cd5\u306e\u3072\u3068\u3064\u306b\u3001\u6b21\u306e\u3088\u3046\u306a\u8a18\u8ff0\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre><code>\r\n\r\n&lt;svg width=&quot;320&quot; height=&quot;320&quot;&gt;\r\n&lt;image xlink:href=&quot;a.svg&quot; \r\nsrc=&quot;a.png&quot; width=&quot;320&quot; height=&quot;320&quot; \/&gt;\r\n&lt;\/svg&gt;\r\n\r\n<\/code><\/pre>\n<p>SVG \u5bfe\u5fdc\u30d6\u30e9\u30a6\u30b6\u3067\u306f\u3001xlink:href \u306e SVG \u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u304c\u3001\u5bfe\u5fdc\u3057\u3066\u3044\u306a\u3044\u30d6\u30e9\u30a6\u30b6\u3067\u306f\u3001SVG \u306e\u8a18\u8ff0\u306f\u7121\u8996\u3055\u308c\u3001image \u8981\u7d20\u306f img \u30bf\u30b0\u3068\u89e3\u91c8\u3055\u308c\u3066 src \u306e PNG \u30d5\u30a1\u30a4\u30eb\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3060\u3060\u3057\u3001\u3053\u306e\u65b9\u6cd5\u306f\u3001SVG \u306b\u5bfe\u5fdc\u3057\u3066\u3044\u308b IE9\u300110\u300111 \u3067\u3001xlink:href \u306e SVG \u30d5\u30a1\u30a4\u30eb\u3068 src \u306e PNG \u30d5\u30a1\u30a4\u30eb\u306e\u4e21\u65b9\u304c\u53d6\u308a\u8fbc\u307e\u308c\u308b\u3053\u3068\u304c\u308f\u304b\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u70b9\u3092\u3075\u307e\u3048\u3066\u3001PHP \u3067\u306e IE \u30d0\u30fc\u30b8\u30e7\u30f3\u5224\u5b9a\u3092\u3082\u3068\u306b\u3001SVG Fallbacks \u30b3\u30fc\u30c9\u3092 WordPress Shortcode \u304b\u3089\u51fa\u529b\u3057\u3066\u8a66\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u30c6\u30fc\u30de\u306e\u305f\u3081\u306e\u95a2\u6570\uff08functions.php\uff09\u306b\u66f8\u304d\u52a0\u3048\u307e\u3059\u3002<\/p>\n<pre><code>\r\n\r\nfunction get_svg_fallbacks( $atts ) {\r\n\r\n  $uah = &quot;&quot;;\r\n  if ( isset( $_SERVER[&quot;HTTP_USER_AGENT&quot;] ) ):\r\n    $uah = $_SERVER[&quot;HTTP_USER_AGENT&quot;];\r\n  endif;\r\n\r\n  if(preg_match(&quot;\/MSIE [5678]\/&quot;,$uah)):\r\n    $outputhtml =\r\n  &#039;&lt;img width=&quot;&#039; . $atts&#091;&#039;width&#039;&#093;\r\n  . &#039;&quot; height=&quot;&#039; . $atts&#091;&#039;height&#039;&#093;\r\n  . &#039;&quot; src=&quot;&#039; . $atts&#091;&#039;imgsrc&#039;&#093;\r\n  . &#039;&quot; \/&gt;&#039;;\r\n  elseif(preg_match(&quot;\/Trident\\\/[567]\/&quot;,$uah)):\r\n    $outputhtml =\r\n  &#039;&lt;svg width=&quot;&#039; . $atts&#091;&#039;width&#039;&#093;\r\n  . &#039;&quot; height=&quot;&#039; . $atts&#091;&#039;height&#039;&#093;\r\n  . &#039;&quot;&gt;&#039;\r\n  . &#039;&lt;image width=&quot;&#039; . $atts&#091;&#039;width&#039;&#093;\r\n  . &#039;&quot; height=&quot;&#039; . $atts&#091;&#039;height&#039;&#093;\r\n  . &#039;&quot; xlink:href=&quot;&#039; . $atts&#091;&#039;svgsrc&#039;&#093;\r\n  . &#039;&quot; \/&gt;&#039;\r\n  . &#039;&lt;\/svg&gt;&#039;;\r\n  else:\r\n    $outputhtml =\r\n  &#039;&lt;svg width=&quot;&#039; . $atts&#091;&#039;width&#039;&#093;\r\n  . &#039;&quot; height=&quot;&#039; . $atts&#091;&#039;height&#039;&#093;\r\n  . &#039;&quot;&gt;&#039;\r\n  . &#039;&lt;image width=&quot;&#039; . $atts&#091;&#039;width&#039;&#093;\r\n  . &#039;&quot; height=&quot;&#039; . $atts&#091;&#039;height&#039;&#093;\r\n  . &#039;&quot; xlink:href=&quot;&#039; . $atts&#091;&#039;svgsrc&#039;&#093;\r\n  . &#039;&quot; src=&quot;&#039; . $atts&#091;&#039;imgsrc&#039;&#093;\r\n  . &#039;&quot; \/&gt;&#039;\r\n  . &#039;&lt;\/svg&gt;&#039;;\r\n  endif;\r\n  return $outputhtml;\r\n}\r\n\r\nadd_shortcode(&#039;svg_fallbacks&#039;,\r\n &#039;get_svg_fallbacks&#039;);\r\n\r\n<\/code><\/pre>\n<p>WordPress \u306e\u6295\u7a3f\u8a18\u4e8b\u4e2d\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre><code>\r\n\r\n[svg_fallbacks\r\n width=&quot;320&quot;\r\n height=&quot;320&quot;\r\n svgsrc=&quot;a.svg&quot;\r\n imgsrc=&quot;a.png&quot;]\r\n\r\n<\/code><\/pre>\n<p><!--more--><\/p>\n<p>\u8868\u793a\u4f8b\u3067\u3059\u3002<a href=\"http:\/\/appw.jp\/2014\/?p=47\">http:\/\/appw.jp\/2014\/?p=47<\/a><\/p>\n<svg width=\"320\" height=\"320\"><image width=\"320\" height=\"320\" xlink:href=\"\/\/appw.jp\/images\/ChatSample.svg\" src=\"http:\/\/appw.jp\/2014\/files\/2014\/07\/sketch-140467369307801.jpg\" \/><\/svg>\n","protected":false},"excerpt":{"rendered":"<p>WordPress \u306e\u8a18\u4e8b\u6295\u7a3f\u3067\u306f\u3001\u5b9f\u884c\u3092\u76ee\u7684\u3068\u3057\u305f PHP \u30d7\u30ed\u30b0\u30e9\u30e0\u30b3\u30fc\u30c9\u3092\u542b\u3081\u308b\u305f\u3081\u306b\u3001Shortcode API \u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e WordPress \u306e short API \u3092\u8a66\u3057\u3066\u307f\u308b\u306e\u3068\u3042\u308f\u305b\u3066\u3001SVG Fallbacks \u3082\u8a66\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=31"}],"version-history":[{"count":10,"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":34,"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions\/34"}],"wp:attachment":[{"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appw.jp\/2016\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}