mirror of
https://github.com/nikdoof/website-hugo.git
synced 2025-12-14 03:22:17 +00:00
Improve the image shortcode
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
{{ $img := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }}
|
||||
{{ $img = $img.Resize "1256x jpg" }}
|
||||
<figure class="image">
|
||||
<img src="{{ $img.RelPermalink }}" width="{{ $img.Width }}" height="{{ $img.Height }}">`
|
||||
{{ $img := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) }}
|
||||
{{ $width := .Get "width" }}
|
||||
{{ $img = $img.Resize (print (default "1256x" $width) " jpg") }}
|
||||
{{ $title := .Get "title" }}
|
||||
{{ $class := .Get "class" }}
|
||||
<figure class="image{{ if $class }} {{ $class }}{{ end }}">
|
||||
<img src="{{ $img.RelPermalink }}" width="{{ $img.Width }}" height="{{ $img.Height }}"{{ if $title }} alt="{{ $title }}"{{ end }}>
|
||||
{{ if $title }}
|
||||
<figcaption class="is-size-6">
|
||||
<small>
|
||||
{{ $title }}
|
||||
</small>
|
||||
</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
||||
@@ -1,24 +0,0 @@
|
||||
{{ $img := .Page.Resources.GetMatch (printf "*%s*" (.Get 0)) }}
|
||||
{{ $command := .Get 1 }}
|
||||
{{ $options := .Get 2 }}
|
||||
{{ if eq $command "Fit"}}
|
||||
{{ $img = $img.Fit $options }}
|
||||
{{ else if eq $command "Resize"}}
|
||||
{{ $img = $img.Resize $options }}
|
||||
{{ else if eq $command "Fill"}}
|
||||
{{ $img = $img.Fill $options }}
|
||||
{{ else if eq $command "Crop"}}
|
||||
{{ $img = $img.Crop $options }}
|
||||
{{ else }}
|
||||
{{ errorf "Invalid image processing command: Must be one of Crop, Fit, Fill or Resize."}}
|
||||
{{ end }}
|
||||
<figure class="image">
|
||||
<img src="{{ $img.RelPermalink }}" width="{{ $img.Width }}" height="{{ $img.Height }}">
|
||||
<figcaption>
|
||||
<small>
|
||||
{{ with .Inner }}
|
||||
{{ . }}
|
||||
{{ end }}
|
||||
</small>
|
||||
</figcaption>
|
||||
</figure>
|
||||
Reference in New Issue
Block a user