diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -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; |