aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain d'Alverny <rda@mageia.org>2011-05-25 17:13:15 +0000
committerRomain d'Alverny <rda@mageia.org>2011-05-25 17:13:15 +0000
commit3c057b20907a9572c6f48793a41923b41b61d51b (patch)
tree1a6063f615bb3d8e4e85d18238512896897933f1
parent0560fea4bea87c24844985f3730bd7fdebb13cf7 (diff)
downloadhugs-3c057b20907a9572c6f48793a41923b41b61d51b.tar
hugs-3c057b20907a9572c6f48793a41923b41b61d51b.tar.gz
hugs-3c057b20907a9572c6f48793a41923b41b61d51b.tar.bz2
hugs-3c057b20907a9572c6f48793a41923b41b61d51b.tar.xz
hugs-3c057b20907a9572c6f48793a41923b41b61d51b.zip
use EXIF COMMENT field if available
-rw-r--r--index.php16
1 files 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 = '<img id="hi" src="%s" alt="Free Hugs!" title="Come get a hug!">';
$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('<figcaption id="hicomment">%s</figcaption>',
+ nl2br($exif['COMMENT'][0]));
+ }
+ $out = sprintf('<figure>%s</figure>', $out);
+
} else {
+
$out = '<div id="hi"><p>404 Hug Not Found :(</p></div>';
}
@@ -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;