<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Gallery on Miek Gieben</title>
    <link>https://miek.nl/tags/gallery/</link>
    <description>Recent content in Gallery on Miek Gieben</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <copyright>© Copyright 2007-2024 Miek Gieben</copyright>
    <lastBuildDate>Tue, 21 Nov 2023 16:27:45 +0100</lastBuildDate>
    <atom:link href="https://miek.nl/tags/gallery/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Gallery Shortcode</title>
      <link>https://miek.nl/2023/november/21/gallery-shortcode/</link>
      <pubDate>Tue, 21 Nov 2023 16:27:45 +0100</pubDate>
      <guid>https://miek.nl/2023/november/21/gallery-shortcode/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m using the following shortcode (saved as &lt;code&gt;gallery.html&lt;/code&gt;) in Hugo to generate a gallery containing&#xA;both video and photos. Comments in the code.&lt;/p&gt;&#xA;&lt;p&gt;May it be helpful for you. It comes (of course) with no support. The cover photo handling is done by&#xA;my Hugo theme (terminal) btw.&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-go-tmpl&#34; data-lang=&#34;go-tmpl&#34;&gt;&amp;lt;!--&#xA;    All img/*.{webm,ogv} video files are taken and simularly the caption file is used&#xA;    to generate a video control.&#xA;--&amp;gt;&#xA;&#xA;{{- $videos := .Page.Resources.Match &amp;#34;img/*.webm&amp;#34; -}}&#xA;{{- $videos = $videos | append ( .Page.Resources.Match &amp;#34;img/*.ogv&amp;#34; ) -}}&#xA;{{- range $videos -}}&#xA;    {{- $caption := &amp;#34;&amp;#34; -}}&#xA;    {{- $captionfile :=  printf &amp;#34;%s.%s&amp;#34; ( strings.TrimSuffix (path.Ext .RelPermalink) .RelPermalink ) &amp;#34;txt&amp;#34; -}}&#xA;    {{- if os.FileExists $captionfile -}}&#xA;        {{ $caption = os.ReadFile $captionfile | markdownify -}}&#xA;    {{- end -}}&#xA;    {{- $type := printf &amp;#34;%s/%s&amp;#34; &amp;#34;video&amp;#34; (slicestr (path.Ext .RelPermalink) 1) -}}&#xA;    {{- $type = replace $type &amp;#34;ogv&amp;#34; &amp;#34;ogg&amp;#34; -}}&#xA;    &amp;lt;figure&amp;gt;&#xA;    &amp;lt;video controls preload=&amp;#34;auto&amp;#34; width=&amp;#34;100%&amp;#34; playsinline class=&amp;#34;html-video&amp;#34;&amp;gt;&#xA;        &amp;lt;source src=&amp;#34;{{ .RelPermalink }}&amp;#34; type=&amp;#34;{{ $type }}&amp;#34;&amp;gt;&#xA;    &amp;lt;/video&amp;gt;&#xA;    {{- if $caption -}}&#xA;        &amp;lt;figcaption&amp;gt;&#xA;            &amp;lt;p&amp;gt;{{ $caption }}&amp;lt;/p&amp;gt;&#xA;        &amp;lt;/figcaption&amp;gt;&#xA;    {{- end -}}&#xA;    &amp;lt;/figure&amp;gt;&#xA;{{ end }}&#xA;&#xA;&amp;lt;link rel=&amp;#34;stylesheet&amp;#34; href=&amp;#34;https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.1/css/lightbox.min.css&amp;#34; integrity=&amp;#34;sha256-tBxlolRHP9uMsEFKVk+hk//ekOlXOixLKvye5W2WR5c=&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34; /&amp;gt;&#xA;&amp;lt;script src=&amp;#34;https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js&amp;#34; integrity=&amp;#34;sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34;&amp;gt;&amp;lt;/script&amp;gt;&#xA;&amp;lt;script src=&amp;#34;https://cdnjs.cloudflare.com/ajax/libs/lightbox2/2.11.1/js/lightbox.min.js&amp;#34; integrity=&amp;#34;sha256-CtKylYan+AJuoH8jrMht1+1PMhMqrKnB8K5g012WN5I=&amp;#34; crossorigin=&amp;#34;anonymous&amp;#34;&amp;gt;&amp;lt;/script&amp;gt;&#xA;&#xA;&amp;lt;!--&#xA;    The galleries must be all lowercase otherwise the caption are not found.&#xA;    We use a flexport to show 3 photos in a row, and that should work in mobile as well.&#xA;    Thumbs are generated on the fly.&#xA;&#xA;    Each gallery is placed under a content/galleries as:&#xA;&#xA;        content/galleries/album1&#xA;            /index.md - normal index stuff, with the &amp;#39;gallery &amp;#39;short code in it.&#xA;            img/      - symlink to all photos (and captions)&#xA;            cover.jpg -&amp;gt; img/cover.jpg  - if exist, this will be used as the cover image.&#xA;            video.webm -&amp;gt; see snippet above&#xA;&#xA;    In the photo directory a .txt file with the same basename as the photo is used as&#xA;    a caption. This is in markdown format. The cover.jpg (or whatever extension) is skipped&#xA;    when generating the gallery.&#xA;&#xA;    Clicking used the lightbox JS to show a slideshow like thing - I may selfhost the javascript&#xA;    at some point.&#xA;--&amp;gt;&#xA;&#xA;{{ $image := (.Page.Resources.ByType &amp;#34;image&amp;#34;) }}&#xA;{{ $i := 0 }}&#xA;{{ with $image }}&#xA;    {{ range . }}&#xA;    {{ if not ( hasPrefix .Name &amp;#34;cover.&amp;#34; ) }}&#xA;        {{ if not ( hasPrefix .Name &amp;#34;img/cover.&amp;#34; ) }}&#xA;            {{ if eq (mod $i 3) 0 }}&#xA;                &amp;lt;div class=&amp;#34;flex-container&amp;#34;&amp;gt;&#xA;            {{ end }}&#xA;            {{ $resized := .Fill &amp;#34;300x230 q70&amp;#34; }}&#xA;            {{ $caption := &amp;#34;&amp;#34; }}&#xA;            {{ $captionfile :=  printf &amp;#34;%s.%s&amp;#34; ( strings.TrimSuffix (path.Ext .RelPermalink) .RelPermalink ) &amp;#34;txt&amp;#34; }}&#xA;            {{ if os.FileExists $captionfile }}&#xA;                {{ $caption = os.ReadFile $captionfile | markdownify }}&#xA;            {{ end }}&#xA;            &amp;lt;div style=&amp;#34;width:{{ $resized.Width }}px&amp;#34;&amp;gt;&#xA;                &amp;lt;figure&amp;gt;&#xA;                    &amp;lt;a href=&amp;#34;{{ .Permalink }}&amp;#34; data-lightbox=&amp;#34;x&amp;#34; data-title=&amp;#34;{{ $caption }}&amp;#34;&amp;gt;&#xA;                    &amp;lt;img loading=&amp;#34;lazy&amp;#34; src=&amp;#34;{{ $resized.Permalink }}&amp;#34; /&amp;gt;&#xA;                &amp;lt;/a&amp;gt;&#xA;                {{ if $caption }}&#xA;                  &amp;lt;figcaption&amp;gt;&#xA;                    &amp;lt;p&amp;gt;{{ $caption }}&amp;lt;/p&amp;gt;&#xA;                  &amp;lt;/figcaption&amp;gt;&#xA;                {{- end }}&#xA;                &amp;lt;/figure&amp;gt;&#xA;            &amp;lt;/div&amp;gt;&#xA;            {{ if eq (mod $i 3) 2 }}&#xA;                &amp;lt;/div&amp;gt;&#xA;            {{ end }}&#xA;            {{ $i = add $i 1 }}&#xA;        {{ end }}&#xA;    {{ end }}&#xA;    {{ end }}&#xA;{{ end }}&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
  </channel>
</rss>
