summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-06-15 12:47:25 +0300
committerPaul Buetow <paul@buetow.org>2026-06-15 12:47:25 +0300
commit3adeaa68af3bac73450a4156edb51fd1ec88347a (patch)
tree2962fbadd005c51fa82206de3a6982377f262969
parent840585ffc6f879b3e48e508a36da10471025e142 (diff)
Add EXIF mouse-over tooltip to the normal image view
The details view already showed a title="" hover summary (camera, aperture, ISO, shutter, date) on its image; the normal image view did not. Wire the same tooltip into view.tmpl: - render_view_page now computes the EXIF tooltip via photo_exif_tooltip_text (reusing the shared identify cache, so no extra ImageMagick work) and passes it as the exif_tooltip context var. - exif_tooltip is now a required render field for the view template too. - view.tmpl adds the title="" attribute to its <img> when the summary is non-empty, mirroring details.tmpl (no title when there is no EXIF). - Tests: extend the EXIF render test to assert the view image carries the same tooltip, and update the required-context-vars expectation for view. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
-rwxr-xr-xbin/shuriken12
-rw-r--r--share/templates/default/view.tmpl10
-rw-r--r--src/lib/album.source.sh10
-rw-r--r--src/lib/template.source.sh2
-rwxr-xr-xtests/cli.sh6
5 files changed, 34 insertions, 6 deletions
diff --git a/bin/shuriken b/bin/shuriken
index c958ee1..8fafb3b 100755
--- a/bin/shuriken
+++ b/bin/shuriken
@@ -619,7 +619,7 @@ declare -ra TEMPLATE_RENDER_FIELD_SPECS=(
'render_current_date_text|current_date_html|||'
'render_enter_page_html|context_html|enter_page|enter_page|splash'
'render_exif_details_html|context_raw|exif_details|exif_details|details'
- 'render_exif_tooltip_html|context_html|exif_tooltip|exif_tooltip|details'
+ 'render_exif_tooltip_html|context_html|exif_tooltip|exif_tooltip|details view'
'render_height_html|config_html|HEIGHT||'
'render_html_dir_html|context_html|html_dir|html_dir|*'
'render_maxpreviews_html|config_html|MAXPREVIEWS||'
@@ -1605,6 +1605,7 @@ render_view_page() {
local -r preview_num="$1"; shift
local -r photo_file="$1"; shift
local animation_class
+ local exif_tooltip_text
template header "$page_num-$preview_num.html" \
html_dir "$html_dir" \
@@ -1614,6 +1615,12 @@ render_view_page() {
show_header_bar 'no'
animation_class=$(random_animation_css_class fast "$photo_file")
+ # Reuse the same EXIF tooltip as the details page so hovering the image in
+ # the normal view shows the camera/exposure summary (reads the shared
+ # identify cache, so no extra ImageMagick work).
+ exif_tooltip_text=$(
+ photo_exif_tooltip_text "$photo_file" "$INCOMING_DIR/$photo_file"
+ )
template view "$page_num-$preview_num.html" \
html_dir "$html_dir" \
backhref "$backhref" \
@@ -1621,7 +1628,8 @@ render_view_page() {
page_num "$page_num" \
preview_num "$preview_num" \
photo "$photo_file" \
- animation_class "$animation_class"
+ animation_class "$animation_class" \
+ exif_tooltip "$exif_tooltip_text"
template footer "$page_num-$preview_num.html" \
html_dir "$html_dir" \
backhref "$backhref" \
diff --git a/share/templates/default/view.tmpl b/share/templates/default/view.tmpl
index b62d566..c6a0e7e 100644
--- a/share/templates/default/view.tmpl
+++ b/share/templates/default/view.tmpl
@@ -1,7 +1,15 @@
+# A non-empty EXIF summary becomes a title="" attribute so hovering the image
+# shows the camera/exposure details, mirroring the details view.
+if [ -n "$render_exif_tooltip_html" ]; then
+ render_exif_tooltip_attr=" title=\"$render_exif_tooltip_html\""
+else
+ render_exif_tooltip_attr=''
+fi
+
cat <<END
<div class='view'>
<a href="${render_page_num_html}-${render_view_next_html}.html">
- <img class='view ${render_animation_class_html}' border='0' src='${render_backhref_html}/${render_photos_dir_html}/${render_photo_html}' />
+ <img class='view ${render_animation_class_html}' border='0' src='${render_backhref_html}/${render_photos_dir_html}/${render_photo_html}'${render_exif_tooltip_attr} />
</a>
<div class="navigator">
<a href="${render_page_num_html}-${render_view_prev_html}.html" class="arrow">&lArr;</a>
diff --git a/src/lib/album.source.sh b/src/lib/album.source.sh
index 57727d3..4914642 100644
--- a/src/lib/album.source.sh
+++ b/src/lib/album.source.sh
@@ -91,6 +91,7 @@ render_view_page() {
local -r preview_num="$1"; shift
local -r photo_file="$1"; shift
local animation_class
+ local exif_tooltip_text
template header "$page_num-$preview_num.html" \
html_dir "$html_dir" \
@@ -100,6 +101,12 @@ render_view_page() {
show_header_bar 'no'
animation_class=$(random_animation_css_class fast "$photo_file")
+ # Reuse the same EXIF tooltip as the details page so hovering the image in
+ # the normal view shows the camera/exposure summary (reads the shared
+ # identify cache, so no extra ImageMagick work).
+ exif_tooltip_text=$(
+ photo_exif_tooltip_text "$photo_file" "$INCOMING_DIR/$photo_file"
+ )
template view "$page_num-$preview_num.html" \
html_dir "$html_dir" \
backhref "$backhref" \
@@ -107,7 +114,8 @@ render_view_page() {
page_num "$page_num" \
preview_num "$preview_num" \
photo "$photo_file" \
- animation_class "$animation_class"
+ animation_class "$animation_class" \
+ exif_tooltip "$exif_tooltip_text"
template footer "$page_num-$preview_num.html" \
html_dir "$html_dir" \
backhref "$backhref" \
diff --git a/src/lib/template.source.sh b/src/lib/template.source.sh
index 8e5b93e..026e3ce 100644
--- a/src/lib/template.source.sh
+++ b/src/lib/template.source.sh
@@ -152,7 +152,7 @@ declare -ra TEMPLATE_RENDER_FIELD_SPECS=(
'render_current_date_text|current_date_html|||'
'render_enter_page_html|context_html|enter_page|enter_page|splash'
'render_exif_details_html|context_raw|exif_details|exif_details|details'
- 'render_exif_tooltip_html|context_html|exif_tooltip|exif_tooltip|details'
+ 'render_exif_tooltip_html|context_html|exif_tooltip|exif_tooltip|details view'
'render_height_html|config_html|HEIGHT||'
'render_html_dir_html|context_html|html_dir|html_dir|*'
'render_maxpreviews_html|config_html|MAXPREVIEWS||'
diff --git a/tests/cli.sh b/tests/cli.sh
index a78741a..f01c2e0 100755
--- a/tests/cli.sh
+++ b/tests/cli.sh
@@ -3846,7 +3846,7 @@ preview:animation_class backhref html_dir page_num photo preview_num thumbs_dir
redirect:html_dir redirect_page
splash:backhref background_image blurs_dir enter_page html_dir photo photos_dir
stats:backhref html_dir stats_body
-view:animation_class backhref html_dir page_num photo photos_dir preview_num
+view:animation_class backhref exif_tooltip html_dir page_num photo photos_dir preview_num
END
)
output=$(
@@ -4785,6 +4785,10 @@ test_generate_renders_exif_details() {
details_html=$(<"$TEST_TMPDIR/dist/1-1-details.html")
test::assert_contains 'href="1-1-details.html">Details</a>' "$view_html"
+ # The normal image view carries the same EXIF tooltip as the details view.
+ test::assert_contains \
+ 'title="Camera: ExampleCam Model &amp; &quot;X&quot;; Aperture: f/2.8; ISO: 400; Shutter speed: 1/125; Taken: 2026:06:04 12:34:56"' \
+ "$view_html"
test::assert_contains '<table class="details">' "$details_html"
test::assert_contains \
'title="Camera: ExampleCam Model &amp; &quot;X&quot;; Aperture: f/2.8; ISO: 400; Shutter speed: 1/125; Taken: 2026:06:04 12:34:56"' \