Skip to content

Commit

Permalink
Merge pull request #1038 from gethinode/develop
Browse files Browse the repository at this point in the history
Fix image portrait mode
  • Loading branch information
markdumay committed Jul 17, 2024
2 parents 600b487 + d8929da commit 8c3ea99
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
1 change: 1 addition & 0 deletions assets/scss/components/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}

.datatable-sorter {
padding-left: 0;
padding-right: 1rem;
}

Expand Down
5 changes: 3 additions & 2 deletions exampleSite/content/en/blog/bootstrap-elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,12 @@ As an example, the following shortcodes show a square check, a brand logo, a cir

## Image

As an example, the following shortcode displays an image with rounded corners and a 21x9 aspect ratio.
As an example, the following shortcode displays an image with rounded corners and a 4x3 aspect ratio in portrait mode.

<!-- markdownlint-disable MD037 -->
{{< example lang="hugo" >}}
{{</* image src="img/flowers.jpg" ratio="21x9" caption="Figure caption" class="rounded" */>}}
{{</* image src="img/flowers.jpg" ratio="4x3" caption="Figure caption" class="rounded col-md-6"
portrait=true wrapper="text-center" */>}}
{{< /example >}}
<!-- markdownlint-enable MD037 -->

Expand Down
1 change: 1 addition & 0 deletions exampleSite/hugo_stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"col-md-2",
"col-md-3",
"col-md-4",
"col-md-6",
"col-md-8",
"col-md-9",
"col-md-auto",
Expand Down
1 change: 1 addition & 0 deletions layouts/partials/assets/helpers/image-definition.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"page" $page
"url" .url
"ratio" $ratio
"portrait" $portrait
"plain" $plain
"imageset" true
) }}
Expand Down
26 changes: 22 additions & 4 deletions layouts/partials/assets/helpers/image-dimension.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{{- $page := .page -}}
{{- $url := .url -}}
{{- $ratio := .ratio -}}
{{- $portrait := .portrait -}}
{{- $height := .height -}}
{{- $width := .width -}}
{{- $plain := .plain | default false }}
Expand Down Expand Up @@ -84,10 +85,27 @@

<!-- Derive image width and height -->
{{ if not $plain }}
{{ with $dims }}
{{ range $dim := (. | last 1) }}
{{ $width = (int (index (split $dim "x") 0)) }}
{{ $height = (int (index (split $dim "x") 1)) }}
{{ if $portrait }}
{{ with $dims }}
{{ $newDims := slice }}
{{ range $dim := . }}
{{ $width = (int (index (split $dim "x") 1)) }}
{{ $height = (int (index (split $dim "x") 0)) }}
{{- $newDims = $newDims | append (printf "%dx%d" (int $width) $height ) -}}
{{ end }}
{{ $dims = $newDims }}
{{ end }}

{{ $newWidth := $height }}
{{ $newHeight := $width }}
{{ $width = $newWidth }}
{{ $height = $newHeight }}
{{ else }}
{{ with $dims }}
{{ range $dim := (. | last 1) }}
{{ $width = (int (index (split $dim "x") 0)) }}
{{ $height = (int (index (split $dim "x") 1)) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
Expand Down

0 comments on commit 8c3ea99

Please sign in to comment.