Files
hugo/layouts/shortcodes/gallery.html
kbrianngeno 6330092560
Some checks failed
Blowfish Docs Deploy / build (push) Has been cancelled
Blowfish Docs Deploy / deploy (push) Has been cancelled
Test Build / Build Example Site (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Update Hugo version / updateBlowfish (push) Has been cancelled
First commit
Delete exampleSite
Add initial content, images & docker-compose.yml
Use extend-head.html for analytics
Set remote url to gitea.novicelab.io
Remove original .git due to "shallow update not allowed" error
2026-03-14 14:43:39 +00:00

32 lines
1.1 KiB
HTML

{{ $id := delimit (slice "gallery" (partial "functions/uid.html" .)) "-" -}}
{{ $content := .Inner -}}
{{/* find all img tags */}}
{{ range findRE `<img\s+[^>]*>` $content -}}
{{ $imgTag := . -}}
{{/* extract src attribute */}}
{{ with findRESubmatch `src=['"]([^'"]+)['"]` $imgTag -}}
{{ $srcAttr := index (index . 0) 0 -}}
{{ $srcValue := index (index . 0) 1 -}}
{{ $srcValueFinal := $srcValue -}}
{{ if or (hasPrefix $srcValue "http://") (hasPrefix $srcValue "https://") -}}
{{ with resources.GetRemote $srcValue -}}{{ $srcValueFinal = .RelPermalink -}}{{ end -}}
{{ else -}}
{{ with $.Page.Resources.GetMatch $srcValue -}}
{{ $srcValueFinal = .RelPermalink -}}
{{ else -}}
{{ with resources.GetMatch $srcValue -}}{{ $srcValueFinal = .RelPermalink -}}{{ end -}}
{{ end -}}
{{ end -}}
{{ $newTag := replace $imgTag $srcAttr (printf `src="%s"` $srcValueFinal) -}}
{{ $content = replace $content $imgTag $newTag -}}
{{ end -}}
{{ end -}}
{{ if not .Parent }}<div class="width-patch"></div>{{ end }}
<div id="{{- $id -}}" class="gallery">
{{ $content | safeHTML -}}
</div>