<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Media Library &#8211; WordPress Memo</title>
	<atom:link href="https://blog.riverforest-wp.info/tag/media-library/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.riverforest-wp.info</link>
	<description>WordPress に関する覚え書き</description>
	<lastBuildDate>Fri, 09 May 2025 12:48:52 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.riverforest-wp.info/wp-content/uploads/2018/05/cropped-icon-256x256-1-32x32.png</url>
	<title>Media Library &#8211; WordPress Memo</title>
	<link>https://blog.riverforest-wp.info</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Snippet for &#8220;Exif Details&#8221;</title>
		<link>https://blog.riverforest-wp.info/exif-details-snippet/</link>
		
		<dc:creator><![CDATA[Katsushi Kawamori]]></dc:creator>
		<pubDate>Fri, 08 May 2020 22:10:27 +0000</pubDate>
				<category><![CDATA[Filter]]></category>
		<category><![CDATA[Caption]]></category>
		<category><![CDATA[Exif]]></category>
		<category><![CDATA[Exif Details]]></category>
		<category><![CDATA[Google Map]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[Media Library]]></category>
		<guid isPermaLink="false">https://blog.riverforest-wp.info/?p=2301</guid>

					<description><![CDATA[Introduction Exif Details plugin has been released. Here is a snippet that uses it. How it works Snippet]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">Introduction</h3>



<p>Exif Details plugin has been released. Here is a snippet that uses it.</p>



<div class="pluginstatsview-card-wrap">
	<div>
		<img decoding="async" src="https://ps.w.org/exif-details/assets/icon-256x256.png?rev=2298875" alt="Exif Details のアイコン" class="pluginstatsview-card-icon" />
		<div class="pluginstatsview-after-icon">
			<div class="pluginstatsview-bold"><a href="https://wordpress.org/plugins/exif-details/" class="pluginstatsview-astyle">Exif Details</a></div>
			<div class="pluginstatsview-small">メディアファイルの詳細な EXIF 情報を取得します。</div>
			<div class="pluginstatsview-small">作者: <a href="https://profiles.wordpress.org/katsushi-kawamori/">Katsushi Kawamori</a></div>
			<div style="clear: both;"></div>
		</div>
	</div>
	<div style="clear: both;"></div>

	<div class="pluginstatsview-small">
		<span class="pluginstatsview-card-left"><a href="https://wordpress.org/plugins/exif-details/#reviews" title="5.0(5点満点中)" class="pluginstatsview-astyle">	<span class="pluginstatsview-stars">
					<span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span>
			</span>
	</a>(1)</span>
		<span class="pluginstatsview-card-right">最終更新: 2日 前</span>
	</div>
	<div class="pluginstatsview-small">
		<span class="pluginstatsview-card-left">300以上サイトで有効化中</span>
		<span class="pluginstatsview-card-right">検証済み: 7.0</span>
	</div>
	<div class="pluginstatsview-small">
		<span class="pluginstatsview-card-left">ダウンロード: <a href="https://downloads.wordpress.org/plugin/exif-details.1.11.zip" class="dashicons dashicons-download pluginstatsview-download"></a></span>
		<span class="pluginstatsview-card-right">リリース: 2020-05-05</span>
	</div>
	<div class="pluginstatsview-small pluginstatsview-card-center">
		2026-03-31 09:29 時点の統計	</div>
</div>



<h3 class="wp-block-heading">How it works</h3>



<figure class="wp-block-video aligncenter"><video height="720" style="aspect-ratio: 1280 / 720;" width="1280" autoplay controls loop muted src="https://blog.riverforest-wp.info/wp-content/uploads/20200508/exif-details-snippet.mp4"></video></figure>



<h3 class="wp-block-heading">Snippet</h3>



<pre class="prism line-numbers"><code class="language-php language-html">/**  ==================================================
 * The original filter hook('exif_details_data'),
 * which changes the display when retrieving an Exif and storing it in metadata.
 * The following changes the display of the shooting date and time.
 *
 * @param array $exifdatas  exifdatas.
 * @param int   $id  id.
 */
function exif_details_change( $exifdatas, $id ) {
	if ( array_key_exists( 'DateTimeOriginal', $exifdatas ) ) {
		$shooting_date = str_replace( ':', '-', substr( $exifdatas&#91;'DateTimeOriginal'], 0, 10 ) );
		$shooting_time = substr( $exifdatas&#91;'DateTimeOriginal'], 10 );
		$exifdatas&#91;'DateTimeOriginal'] = $shooting_date . $shooting_time;
	}
	return $exifdatas;
}
add_filter( 'exif_details_data', 'exif_details_change', 10, 2 );

/**  ==================================================
 * When adding new media, insert the processed data into the caption.
 * Use the original action hook ('exif_details_update') with function.
 *
 * @param array $metadata  metadata.
 * @param int   $id  id.
 */
function media_caption( $metadata, $id ) {
	$mime_type = get_post_mime_type( $id );
	if ( in_array( $mime_type, array( 'image/jpeg', 'image/tiff' ) ) ) {
		do_action( 'exif_details_update', $id );
		$exifdatas = get_post_meta( $id, '_exif_details', true );
		if ( ! empty( $exifdatas ) ) {
			$camera = null;
			$f_number = null;
			$s_speed = null;
			$iso = null;
			$date = null;
			$googlemap = null;
			if ( array_key_exists( 'Model', $exifdatas ) ) {
				$camera = 'Camera:' . $exifdatas&#91;'Model'];
			}
			if ( array_key_exists( 'ApertureFNumber', $exifdatas ) ) {
				$f_number = 'F-number:' . $exifdatas&#91;'ApertureFNumber'];
			}
			if ( array_key_exists( 'ExposureTime', $exifdatas ) ) {
				$s_speed = 'Shutter speed:' . $exifdatas&#91;'ExposureTime'];
			}
			if ( array_key_exists( 'ISOSpeedRatings', $exifdatas ) ) {
				$isodata = json_decode( $exifdatas&#91;'ISOSpeedRatings'] );
				if ( is_array( $isodata ) ) {
					$iso = 'ISO:' . $isodata&#91;0];
				} else {
					$iso = 'ISO:' . $isodata;
				}
			}
			if ( array_key_exists( 'DateTimeOriginal', $exifdatas ) ) {
				$date = 'Date:' . $exifdatas&#91;'DateTimeOriginal'];
			}
			if ( array_key_exists( 'latitude_dd', $exifdatas ) &amp;&amp; array_key_exists( 'longtitude_dd', $exifdatas ) ) {
				$googlemap = '&lt;a href="https://www.google.com/maps?q=' . $exifdatas&#91;'latitude_dd'] . ',' . $exifdatas&#91;'longtitude_dd'] . '">Google Map&lt;/a>';
			}
			$caption = sprintf( '%1$s %2$s %3$s %4$s %5$s %6$s', $camera, $f_number, $s_speed, $iso, $date, $googlemap );
			$caption = rtrim( $caption );
			$caption = preg_replace( '/\s(?=\s)/', '', $caption );
			$media_post = array(
				'ID'           => $id,
				'post_excerpt' => $caption,
			);
			wp_update_post( $media_post );
		}
	}
	return $metadata;
}
add_filter( 'wp_generate_attachment_metadata', 'media_caption', 10, 2 );</code></pre>
]]></content:encoded>
					
		
		<enclosure url="https://blog.riverforest-wp.info/wp-content/uploads/20200508/exif-details-snippet.mp4" length="26924506" type="video/mp4" />

			</item>
	</channel>
</rss>
