Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Metadata Info Bar #77

Open
timcappalli opened this issue Aug 15, 2024 · 4 comments
Open

Feature Request: Metadata Info Bar #77

timcappalli opened this issue Aug 15, 2024 · 4 comments

Comments

@timcappalli
Copy link

timcappalli commented Aug 15, 2024

It would be awesome to have an option to display the photo metadata (Camera, exposure, aperture, focal length, etc) underneath the title/description text when the photo is expanded.

Here's an example:

image

Thanks for all your work on this awesome theme!

@timcappalli
Copy link
Author

I actually figured out how to do this with the native EXIF parser. If you're accepting pull requests, happy to add it! I'm thinking it can be behind a config flag.

@nicokaiser
Copy link
Owner

You could add a section to gallery.html, inside the gallery-item tag:

        <a class="gallery-item" href="{{ $image.RelPermalink }}" data-pswp-src="{{ $full.RelPermalink }}" data-pswp-width="{{ $full.Width }}" data-pswp-height="{{ $full.Height }}" title="{{ .Title }}" itemscope itemtype="https://schema.org/ImageObject" style="aspect-ratio: {{ $thumbnail.Width }} / {{ $thumbnail.Height }}">
          <img loading="lazy" width="{{ $thumbnail.Width }}" height="{{ $thumbnail.Height }}" src="{{ $thumbnail.RelPermalink }}" style="background-color: {{ $color }}" alt="{{ .Title }}" />
+         {{ if $image.Exif }}
+           <span class="pswp-caption-content">
+             {{ with .Title }}{{ . }}<br />{{ end }}
+             {{ with $image.Exif.Tags }}
+               {{ if .Model }}
+                 {{ .Make }} {{ .Model }} &middot;
+               {{ end }}
+               {{ with .FocalLength }}{{ . }}mm &middot; {{ end }}
+               {{ with .ApertureValue }}f/{{ div (math.Round (mul (float .) 10)) 10 }}{{ end }}
+               {{ with .ExposureTime }}{{ . }}s &middot; {{ end }}
+               {{ with .ISO }}ISO {{ . }}{{ end }}
+             {{ end }}
+           </span>
+         {{ end }}
          <meta itemprop="contentUrl" content="{{ $image.RelPermalink }}" />
          {{ with site.Params.Author }}
            <span itemprop="creator" itemtype="https://schema.org/Person" itemscope>
              <meta itemprop="name" content="{{ site.Params.Author.name }}" />
            </span>
          {{ end }}
        </a>

… and remove the includeFields line from hugo.toml so all EXIF tags are extracted.

@timcappalli
Copy link
Author

Thank you! That is perfect!

Do you know if its possible to include a link in the caption? Whenever I add an <a> </a> tag, nothing from that tag on renders. I assume it is because the caption is part of an <a> tag itself and the engine doesn't know how to deal with it. I tried to do it in a partial but same result.

Essentially I'm trying to add a Google Maps link based on the GPS data:

{{ with $image.Exif.Long }}
    &middot; <a href="https://www.google.com/maps/place/{{ $image.Exif.Lat }},{{ $image.Exif.Long }}">Map</a>
{{ end }}

@inkhey
Copy link

inkhey commented Sep 2, 2024

Thank you! That is perfect!

Do you know if its possible to include a link in the caption? Whenever I add an <a> </a> tag, nothing from that tag on renders. I assume it is because the caption is part of an <a> tag itself and the engine doesn't know how to deal with it. I tried to do it in a partial but same result.

Essentially I'm trying to add a Google Maps link based on the GPS data:

{{ with $image.Exif.Long }}
    &middot; <a href="https://www.google.com/maps/place/{{ $image.Exif.Lat }},{{ $image.Exif.Long }}">Map</a>
{{ end }}

it's an issue with the gallery lightbox configuration, to make it work there are at least 2 requirements:

I made a POC for this, because i wanted to share a local video link from params to the caption: 77bf36e

I don't see others issue with the fix but maybe it broke something else.

PS: The poc also synchronize title attribute value (visible on overlay) of the link/image and the caption, but of course, link in the title cannot be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants