Menampilkan EXIF Data di WordPress

File foto yang diambil dengan kamera digital biasa memiliki metadata/EXIF data yang terkandung di dalamnya. Untuk menampilkannya di halaman WordPress, bisa menggunakan script sederhana berikut ini.

[php]
$imgmeta = wp_get_attachment_metadata( $id );

// Convert the shutter speed retrieve from database to fraction
if ((1 / $imgmeta[‘image_meta’][‘shutter_speed’]) > 1) {
if ((number_format((1 / $imgmeta[‘image_meta’][‘shutter_speed’]), 1)) == 1.3
or number_format((1 / $imgmeta[‘image_meta’][‘shutter_speed’]), 1) == 1.5
or number_format((1 / $imgmeta[‘image_meta’][‘shutter_speed’]), 1) == 1.6
or number_format((1 / $imgmeta[‘image_meta’][‘shutter_speed’]), 1) == 2.5) {
$pshutter = “1/” . number_format((1 / $imgmeta[‘image_meta’][‘shutter_speed’]), 1, ‘.’, ”) . ” second”;
} else {
$pshutter = “1/” . number_format((1 / $imgmeta[‘image_meta’][‘shutter_speed’]), 0, ‘.’, ”) . ” second”;
}
} else {
$pshutter = $imgmeta[‘image_meta’][‘shutter_speed’] . ” seconds”;
}

// Start to display EXIF and IPTC data of digital photograph
echo “Date Taken: ” . date(“d-M-Y H:i:s”, $imgmeta[‘image_meta’][‘created_timestamp’]).”
“;
echo “Copyright: ” . $imgmeta[‘image_meta’][‘copyright’].”
“;
echo “Credit: ” . $imgmeta[‘image_meta’][‘credit’].”
“;
echo “Title: ” . $imgmeta[‘image_meta’][‘title’].”
“;
echo “Caption: ” . $imgmeta[‘image_meta’][‘caption’].”
“;
echo “Camera: ” . $imgmeta[‘image_meta’][‘camera’].”
“;
echo “Focal Length: ” . $imgmeta[‘image_meta’][‘focal_length’].”mm
“;
echo “Aperture: f/” . $imgmeta[‘image_meta’][‘aperture’].”
“;
echo “ISO: ” . $imgmeta[‘image_meta’][‘iso’].”
“;
echo “Shutter Speed: ” . $pshutter . “
“;
[/php]

Selamat mencoba! 😉

Sumber: Turn On WordPress Feature To Display Photo EXIF Data and IPTC Information

Published by Eric Gunawan

Happiness Engineer. WordPress Ambassador. Remote Worker. Soccer News Follower. Movie Lover. Proud Father. Lucky Husband.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: