HUGO
Menu
GitHub 90529 stars Mastodon

images.Config

Returns an image.Config object for the image at the given path, relative to the working directory.
Syntax
images.Config PATH
Returns
image.Config

Usage

The images.Config function returns an image.Config object for the image at the given path, relative to the working directory. Supported image formats include AVIF, BMP, GIF, HEIC, HEIF, JPEG, PNG, TIFF, and WebP.

This is a legacy function. To get the dimensions of a global resource, page resource, or remote resource, use the Width and Height methods instead.

Use these methods on the image.Config object:

Height
(int) Returns the height of the image, in pixels.
Width
(int) Returns the width of the image, in pixels.

Hugo caches the result, so calling the function more than once with the same path does not add overhead.

Examples

{{ $ic := images.Config "/static/images/a.jpg" }}

{{ $ic.Width }} → 600
{{ $ic.Height }} → 400