This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Traverses an arbitrary struct and translates all stings it encounters | |
// | |
// I haven't seen an example for reflection traversing an arbitrary struct, so | |
// I want to share this with you. If you encounter any bugs or want to see | |
// another example please comment. | |
// | |
// The MIT License (MIT) | |
// | |
// Copyright (c) 2014 Heye Vöcking | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ $image := .Params.image}} | |
{{ $media := (.Site.GetPage "page" "media").Resources }} | |
{{ $original := index ($media.Match (printf "%s" $image)) 0 }} | |
{{ $width := $original.Width}} | |
{{ $intWidth := int $width }} | |
{{ $sizes := .Params.sizes}} | |
{{ $options := .Params.options}} | |
{{ if le (len $sizes) 1 }} | |
{{ $oneSize := index $sizes 0}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style> | |
img { | |
max-width: 100%; | |
} | |
</style> | |
<h1>Creating a srcset loop based on Resources</h1> | |
<!-- | |
NOTE: This requires Hugo 0.32 |