diff --git a/content/about/new-in-032.md b/content/about/new-in-032/index.md similarity index 89% rename from content/about/new-in-032.md rename to content/about/new-in-032/index.md index 82e96be4e..4163fbc60 100644 --- a/content/about/new-in-032.md +++ b/content/about/new-in-032/index.md @@ -102,13 +102,6 @@ Type here is `page` for pages, else the main type in the MIME type, so `image`, ## Image Processing -{{% note %}} -There is a known issue with image processing in shortcodes. See https://github.com/gohugoio/hugo/issues/4202 - - -We will fix in a day or two. -{{% /note %}} - The `image` resource implements the methods `Resize`, `Fit` and `Fill`: Resize @@ -126,6 +119,35 @@ Image operations in Hugo currently **do not preserve EXIF data** as this is not {{% /note %}} +### Image Processing Examples + +_The photo of the sunset used in the examples below is Copyright [Bjørn Erik Pedersen](https://commons.wikimedia.org/wiki/User:Bep) (Creative Commons Attribution-Share Alike 4.0 International license)_ + + +{{< imgproc sunset Resize "300x" >}} + +{{< imgproc sunset Fill "90x120 left" >}} + +{{< imgproc sunset Fill "90x120 right" >}} + +{{< imgproc sunset Fit "90x90" >}} + +{{< imgproc sunset Resize "300x q10" >}} + + +This is the shortcode used in the examples above: + + +{{< code file="layouts/shortcodes/imgproc.html" >}} +{{< readfile file="layouts/shortcodes/imgproc.html" >}} +{{< /code >}} + +And it is used like this: + +```html +{{}} +``` + ### Image Processing Options In addition to the dimensions (e.g. `200x100`) where either height or width can be omitted, Hugo supports a set of additional image options: diff --git a/content/about/new-in-032/sunset.jpg b/content/about/new-in-032/sunset.jpg new file mode 100644 index 000000000..7d7307bed Binary files /dev/null and b/content/about/new-in-032/sunset.jpg differ diff --git a/layouts/shortcodes/imgproc.html b/layouts/shortcodes/imgproc.html new file mode 100644 index 000000000..7d7e911fe --- /dev/null +++ b/layouts/shortcodes/imgproc.html @@ -0,0 +1,19 @@ +{{ $original := .Page.Resources.GetByPrefix (.Get 0) }} +{{ $command := .Get 1 }} +{{ $options := .Get 2 }} +{{ if eq $command "Fit"}} +{{ .Scratch.Set "image" ($original.Fit $options) }} +{{ else if eq $command "Resize"}} +{{ .Scratch.Set "image" ($original.Resize $options) }} +{{ else if eq $command "Fill"}} +{{ .Scratch.Set "image" ($original.Fill $options) }} +{{ else }} +{{ errorf "Invalid image processing command: Must be one of fit, fill or resize."}} +{{ end }} +{{ $image := .Scratch.Get "image" }} +
+ +
+ .{{ $command }} "{{ $options }}" +
+
\ No newline at end of file diff --git a/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q10_box_center.jpg b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q10_box_center.jpg new file mode 100644 index 000000000..8736f0376 Binary files /dev/null and b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q10_box_center.jpg differ diff --git a/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q75_box_center.jpg b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q75_box_center.jpg new file mode 100644 index 000000000..47d62fce7 Binary files /dev/null and b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_300x0_resize_q75_box_center.jpg differ diff --git a/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_left.jpg b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_left.jpg new file mode 100644 index 000000000..f9e218242 Binary files /dev/null and b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_left.jpg differ diff --git a/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_right.jpg b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_right.jpg new file mode 100644 index 000000000..fb96b61b6 Binary files /dev/null and b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x120_fill_q75_box_right.jpg differ diff --git a/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x90_fit_q75_box_center.jpg b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x90_fit_q75_box_center.jpg new file mode 100644 index 000000000..b8ad2659f Binary files /dev/null and b/resources/_gen/images/about/new-in-032/sunset_hu59e56ffff1bc1d8d122b1403d34e039f_90587_90x90_fit_q75_box_center.jpg differ