{"id":2411,"date":"2013-08-15T06:37:29","date_gmt":"2013-08-14T21:37:29","guid":{"rendered":"http:\/\/borg4.vdomains.jp\/~goro\/diary\/?p=2411"},"modified":"2013-08-15T06:38:23","modified_gmt":"2013-08-14T21:38:23","slug":"exifcaption","status":"publish","type":"post","link":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/2013\/2411","title":{"rendered":"EXIFCaption"},"content":{"rendered":"<p>\u3044\u3064\u306e\u9803\u304b\u3089\u304b\u3001 WordPress \u3067\u5199\u771f\u3092\u8cbc\u308a\u4ed8\u3051\u308b\u3068\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u3051\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u307e\u3057\u305f\u3002\u5c0f\u6d12\u843d\u305f\u6a5f\u80fd\u3067\u5927\u597d\u304d\u306a\u3093\u3067\u3059\u304c\u3001\u3053\u308c\u306f <a href=\"http:\/\/wpdocs.sourceforge.jp\/%E3%82%B7%E3%83%A7%E3%83%BC%E3%83%88%E3%82%B3%E3%83%BC%E3%83%89_API\">WordPress \u306e\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9<\/a>\u3063\u3066\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u5b9f\u73fe\u3057\u3066\u3044\u308b\u3082\u306e\u306a\u3093\u3060\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u3067\u3001\u5148\u65e5\u306e<a href=\"http:\/\/borg4.vdomains.jp\/~goro\/diary\/2013\/2355\">\u30ec\u30f3\u30ba\u30d7\u30ed\u30c6\u30af\u30bf\u30fc\u304c\u5272\u308c\u305f\u6642\u306e\u30a8\u30f3\u30c8\u30ea<\/a>\u3092\u66f8\u3044\u305f\u6642\u306b\u3001\u5199\u771f\u306e EXIF \u3092\u8868\u793a\u3057\u305f\u304b\u3063\u305f\u306e\u3067\u3001\u9069\u5f53\u306a\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u63a2\u3057\u3066\u3044\u305f\u3068\u3053\u308d <a href=\"http:\/\/fukata.org\/dev\/wp-plugin\/wpexifview\/\">WPExifView<\/a> \u3068\u3044\u3046\u30d7\u30e9\u30b0\u30a4\u30f3\u304c\u3061\u3087\u3046\u3069\u4ffa\u306e\u30cb\u30fc\u30ba\u306b\u5408\u3063\u3066\u305f\u3063\u307d\u304b\u3063\u305f\u306e\u3067\u3053\u308c\u3092\u4f7f\u304a\u3046\u3068\u601d\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u306b\u4f7f\u304a\u3046\u3068\u601d\u3063\u3066\u3082\u4f7f\u3048\u306a\u3044\u2026\u3002\u3068\u3044\u3046\u306e\u306f\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u5185\u3067\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3092\u30cd\u30b9\u30c8\u3057\u3066\u5b9f\u884c\u3059\u308b\u306b\u306f\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u5074\u306e\u5bfe\u5fdc\u304c\u5fc5\u8981\u3063\u307d\u3044\u304b\u3089\u306a\u3093\u3067\u3059\u306d\u3002\u5834\u5f53\u305f\u308a\u7684\u306b\u5f04\u3063\u3066\u3082\u3088\u304b\u3063\u305f\u3093\u3067\u3059\u304c\u3001 WordPress \u672c\u4f53\u3092\u5f04\u308b\u3068\u30d0\u30fc\u30b8\u30e7\u30f3\u30a2\u30c3\u30d7\u6642\u306b\u6ce3\u304d\u3060\u3059\u672a\u6765\u304c\u57a3\u9593\u898b\u3048\u305f\u306e\u3067\u3001\u3060\u3063\u305f\u3089\u81ea\u4f5c\u3059\u308b\u3079\u30fc\u3001\u3068\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u4f7f\u3044\u65b9\u306f WordPress \u3067\u5199\u771f\u3092\u8cbc\u3063\u3066\u3001\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u3092\u66f8\u3044\u3066\u3001\u30c6\u30ad\u30b9\u30c8\u8868\u793a\u30e2\u30fc\u30c9\u306b\u3057\u3066&#091;caption&#093;&#091;\/caption&#093;\u3063\u3066\u306e\u3092&#091;exifcaption&#093;&#091;\/exifcaption&#093;\u3068\u3059\u308b\u3060\u3051\u3002\u5177\u4f53\u7684\u306b\u306f\u3053\u3046\u3002<\/p>\n<figure id=\"attachment_2419\" aria-describedby=\"caption-attachment-2419\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-content\/uploads\/2013\/08\/IMG_5101.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-content\/uploads\/2013\/08\/IMG_5101-300x200.jpg\" alt=\"caption\" width=\"300\" height=\"200\" class=\"size-medium wp-image-2419\" srcset=\"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-content\/uploads\/2013\/08\/IMG_5101-300x200.jpg 300w, https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-content\/uploads\/2013\/08\/IMG_5101-1024x682.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-2419\" class=\"wp-caption-text\">\u3053\u3063\u3061\u306f &#091;caption&#093;&#091;\/caption&#093;<\/figcaption><\/figure>\n<p>[exifcaption id=&#8221;attachment_2419&#8243; align=&#8221;aligncenter&#8221; width=&#8221;300&#8243;]<a href=\"http:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-content\/uploads\/2013\/08\/IMG_5101.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-content\/uploads\/2013\/08\/IMG_5101-300x200.jpg\" alt=\"exifcaption\" width=\"300\" height=\"200\" class=\"size-medium wp-image-2419\" srcset=\"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-content\/uploads\/2013\/08\/IMG_5101-300x200.jpg 300w, https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-content\/uploads\/2013\/08\/IMG_5101-1024x682.jpg 1024w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>\u3053\u3063\u3061\u304c &#091;exifcaption&#093;&#091;\/exifcaption&#093;[\/exifcaption]<\/p>\n<p>\u8868\u793a\u3059\u308b EXIF \u306f\u6c7a\u3081\u6253\u3061\u306a\u306e\u3067\u3001\u5909\u66f4\u3057\u305f\u3044\u4eba\u306f\u30bd\u30fc\u30b9\u3092\u5f04\u3063\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u30bd\u30fc\u30b9\u306f\u3053\u3093\u306a\u611f\u3058\u3002 WordPress \u672c\u4f53\u306e Caption \u3092\u6539\u9020\u3057\u305f\u30b3\u30fc\u30c9\u306a\u306e\u3067\u6b8b\u5ff5\u306a\u304c\u3089 GPL2 \u3067\u3054\u3056\u3044\u307e\u3059\u3002\u4f7f\u3044\u305f\u3044\u4eba\u304c\u3044\u305f\u3089\u3054\u81ea\u7531\u306b\u3069\u30fc\u305e\u3002<\/p>\n<pre>&lt;?php\r\n\/*\r\nPlugin Name: EXIFCaption\r\nPlugin URI: \r\nDescription: Caption with base image EXIF\r\nVersion: 0.1\r\nAuthor: unknown\r\nAuthor URI: ounknown\r\nLicense: GPL2\r\n*\/\r\nadd_shortcode('exifcaption', 'img_exifcaption_shortcode');\r\n\r\nfunction img_exifcaption_shortcode($attr, $content = null) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \/\/ New-style shortcode with the caption inside the shortcode with the link and image tags.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if ( ! isset( $attr['exifcaption'] ) ) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if ( preg_match( '#((?:&lt;a [^&gt;]+&gt;\\s*)?&lt;img [^&gt;]+&gt;(?:\\s*&lt;\/a&gt;)?)(.*)#is', $content, $matches ) ) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $content = $matches[1];\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $attr['exifcaption'] = trim( $matches[2] );\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\r\n\u00a0\u00a0 \u00a0if ( ! isset( $attr['imgfile'] ) ) {\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if ( preg_match( '#href=\"(.*?)\"#is', $content, $matches ) ) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$attr['imgfile'] = trim( $matches[1] );\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0}\r\n\r\n\u00a0\u00a0 \u00a0\/\/ Allow plugins\/themes to override the default caption template.\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 $output = apply_filters('img_exifcaption_shortcode', '', $attr, $content);\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if ( $output != '' )\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return $output;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 extract(shortcode_atts(array(\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'id'\u00a0\u00a0\u00a0 =&gt; '',\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'align' =&gt; 'alignnone',\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'width' =&gt; '',\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0        'imgfile' =&gt; '',\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 'exifcaption' =&gt; ''\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ), $attr, 'exifcaption'));\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if ( $id ) $id = 'id=\"' . esc_attr($id) . '\" ';\r\n\r\n\u00a0\u00a0 \u00a0$args = array( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; -1, 'post_status' =&gt; null, 'post_parent' =&gt; get_the_ID() ); \r\n\u00a0\u00a0 \u00a0$attachments = get_posts($args);\r\n\u00a0\u00a0 \u00a0if ($attachments) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0foreach ( $attachments as $attachment ) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if (wp_get_attachment_url( $attachment-&gt;ID , false ) == $attr['imgfile']) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if ( is_callable( 'exif_read_data' ) ) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$exif = exif_read_data(get_attached_file($attachment-&gt;ID), 0, true);\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0break;\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0}\r\n\u00a0\u00a0 \u00a0}\r\n\r\n\u00a0\u00a0 \u00a0if ( isset ($exif[\"EXIF\"])) {\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0list( $n, $d ) = explode( '\/', $exif[\"EXIF\"][\"FNumber\"] );\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0if ( !empty($d) ) \r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$exif[\"EXIF\"][\"FNumber\"] = $n \/ $d;\r\n\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0$exifstr = \"&lt;pre style=\\\"color: white; background: rgba(0,0,0,0.6); display:block; border: 0px; padding: 2px; margin: 0px;margin-right: 8px;box-shadow: 0px 0px 7px rgb(119, 119, 119);\\\"&gt;&lt;small&gt;\".\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\"Manufacturer\u00a0 : \" . $exif[\"IFD0\"][\"Make\"].\"\\n\".\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\"Model Name\u00a0\u00a0\u00a0 : \" . $exif[\"IFD0\"][\"Model\"].\"\\n\".\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\"Date Time\u00a0\u00a0\u00a0\u00a0 : \" . $exif[\"IFD0\"][\"DateTime\"].\"\\n\".\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\"Exposure Time : \" . $exif[\"EXIF\"][\"ExposureTime\"].\"\\n\".\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\"Focal Length\u00a0 : \" . (float)$exif[\"EXIF\"][\"FocalLength\"].\"mm\".\"\\n\".\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\"F Number\u00a0\u00a0\u00a0\u00a0\u00a0 : \" . $exif[\"EXIF\"][\"FNumber\"].\"\\n\".\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\"ISO\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : \" . $exif[\"EXIF\"][\"ISOSpeedRatings\"].\r\n\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 \u00a0\"&lt;\/small&gt;&lt;\/pre&gt;\";\r\n\u00a0\u00a0 \u00a0}\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if ( 1 &gt; (int) $width || (empty($exifcaption) &amp;&amp; empty($exifstr)) )\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return $content;\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return '&lt;div ' . $id . 'class=\"wp-caption ' . esc_attr($align) . '\" style=\"width: ' . (10 + (int) $width) . 'px\"&gt;'\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 . do_shortcode( $content ) . $exifstr. '&lt;p&gt;'\u00a0 . $exifcaption .'&lt;\/p&gt;&lt;\/div&gt;';\r\n}\r\n\r\n?&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3044\u3064\u306e\u9803\u304b\u3089\u304b\u3001 WordPress \u3067\u5199\u771f\u3092\u8cbc\u308a\u4ed8\u3051\u308b\u3068\u30ad\u30e3\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u3051\u308b\u3053\u3068\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u307e\u3057\u305f\u3002\u5c0f\u6d12\u843d\u305f\u6a5f\u80fd\u3067\u5927\u597d\u304d\u306a\u3093\u3067\u3059\u304c\u3001\u3053\u308c\u306f WordPress \u306e\u30b7\u30e7\u30fc\u30c8\u30b3\u30fc\u30c9\u3063\u3066\u6a5f\u80fd\u3092\u4f7f\u3063\u3066\u5b9f\u73fe\u3057\u3066\u3044\u308b\u3082\u306e\u306a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2419,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[43],"class_list":["post-2411","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-misc","tag-wp"],"_links":{"self":[{"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/posts\/2411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/comments?post=2411"}],"version-history":[{"count":10,"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/posts\/2411\/revisions"}],"predecessor-version":[{"id":2422,"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/posts\/2411\/revisions\/2422"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/media\/2419"}],"wp:attachment":[{"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/media?parent=2411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/categories?post=2411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/borg4.vdomains.jp\/~goro\/diary\/wp-json\/wp\/v2\/tags?post=2411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}