diff options
author | Thedro Neely <thedroneely@gmail.com> | 2021-06-05 23:05:48 -0400 |
---|---|---|
committer | Thedro Neely <thedroneely@gmail.com> | 2021-06-05 23:12:45 -0400 |
commit | 7baf433b53342ab55a32e74f3e3241ed5119032f (patch) | |
tree | 2599f315b3eafa2f2256af19ac9c8d4e4d63d18c /generators/hugo/themes/tdro/layouts/shortcodes/image.html | |
parent | e2c59edb858a03ac44c2440c2a1d571e785b2301 (diff) | |
download | thedroneely.com-7baf433b53342ab55a32e74f3e3241ed5119032f.tar.gz thedroneely.com-7baf433b53342ab55a32e74f3e3241ed5119032f.tar.bz2 thedroneely.com-7baf433b53342ab55a32e74f3e3241ed5119032f.zip |
generators/shortcodes: Footnote and image enhancements
Defensive; hash footnote content and mark ids to ensure no conflicts on side-notes and
images.
Decouple PHP from image short-codes.
Add margin images.
Ensure consistency between foot-notes, side-notes, and side-images.
Diffstat (limited to 'generators/hugo/themes/tdro/layouts/shortcodes/image.html')
-rw-r--r-- | generators/hugo/themes/tdro/layouts/shortcodes/image.html | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/generators/hugo/themes/tdro/layouts/shortcodes/image.html b/generators/hugo/themes/tdro/layouts/shortcodes/image.html index a49ed94..afebef4 100644 --- a/generators/hugo/themes/tdro/layouts/shortcodes/image.html +++ b/generators/hugo/themes/tdro/layouts/shortcodes/image.html @@ -1,15 +1,15 @@ -{{ safeHTML "<?php" }} -$width = getimagesize($_SERVER['DOCUMENT_ROOT'] . '{{.Get `source`}}')[0]; -$height = getimagesize($_SERVER['DOCUMENT_ROOT'] . '{{.Get `source`}}')[1]; -$ratio = ((($height / $width) * 100) > 100) ? $height . 'px' : $height / $width * 100 . '%'; -{{ safeHTML "?>" }} +{{ $imageFile := print "public" (.Get `source`) }} +{{ $image := imageConfig $imageFile }} + +{{ $ratio := 0 }} +{{ if lt (mul (div (float $image.Height) $image.Width) 100) 100 }} +{{ $ratio = mul (div (float $image.Height) $image.Width) 100 }} +{{ end }} <figure> - <a href="{{.Get `source`}}" onclick="return false;"> - <div {{ safeHTMLAttr `<?php echo 'style=' . '"' . 'padding-bottom:' . $ratio . ';' . '"'; ?>` }}> - <img data-image-zoom src="{{.Get `source`}}" alt="{{.Get `title`}}" title="{{.Get `title`}}" - {{ safeHTMLAttr `<?php echo 'width=' . '"' . $width . '"'; ?>` }} - {{ safeHTMLAttr `<?php echo 'height=' . '"' . $height . '"'; ?>` }} /> + <a href="{{ .Get `source` }}" onclick="return false;"> + <div style="padding-bottom: {{ $ratio }}%;"> + <img data-image-zoom src="{{ .Get `source` }}" alt="{{ .Get `title` }}" title="{{ .Get `title` }}" width="{{ $image.Width }}" height="{{ $image.Height }}"/> </div> </a> <figcaption class="has-text-centered has-text-grey-dark">{{ .Inner }}</figcaption> |