From 3c057b20907a9572c6f48793a41923b41b61d51b Mon Sep 17 00:00:00 2001 From: Romain d'Alverny Date: Wed, 25 May 2011 17:13:15 +0000 Subject: use EXIF COMMENT field if available --- index.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 8d52ef0..eb4b008 100644 --- a/index.php +++ b/index.php @@ -16,16 +16,27 @@ */ $app_root = realpath(dirname(__FILE__)); +$images = glob(sprintf('%s/var/hugs/*.jpg', $app_root)); -$images = glob(sprintf('%s/var/hugs/*.jpg', $app_root)); if (count($images) > 0) { + $img_tmpl = 'Free Hugs!'; $img = $images[array_rand($images)]; $out = sprintf($img_tmpl, str_replace($app_root, '', $img)); - // TODO $exif = exif_read_data($img, null, true); + // TIP use jhead -ce photo.jpg to edit photo COMMENT field + $exif = exif_read_data($img, null, true); + if (!is_null($exif) + && isset($exif['COMMENT'])) { + + $out .= sprintf('
%s
', + nl2br($exif['COMMENT'][0])); + } + $out = sprintf('
%s
', $out); + } else { + $out = '

404 Hug Not Found :(

'; } @@ -53,6 +64,7 @@ if (count($images) > 0) { ul { margin-bottom: 4em; } li { margin-bottom: 0.6em; } img { border: 0; } + figure, figcaption { display: block; margin: 0; padding: 0; } #hi { margin: 10px 0 0 0; width: 350px; -webkit-box-shadow: 0 0 40px #555; -moz-box-shadow: 0 0 40px #555; box-shadow: 0 0 40px #555; -- cgit v1.2.1