Enhanced Image Handling
Posted on November 13, 2024 (Last modified on November 22, 2024) • 3 min read • 454 wordsEnhanced image handling for Hugo / Hinode Theme: Improved scaling, optimized load times, and new 'auto' aspect ratio for efficient, responsive visuals.
Date: November 13, 2024
Commit:
5b685f8
Contributor: d-oit
The latest update focuses on improving image handling within the d-oit.github.io site, offering increased flexibility in image scaling and optimizing page load times. The addition of an auto
aspect ratio option and conditional image resizing brings new efficiency and responsiveness to site visuals.
Aspect Ratio Flexibility:
auto
option was added in image.yml
for images, allowing them to retain their native aspect ratio by default. This change adapts better to different screen sizes without requiring specific aspect ratios.Hint: The auto
option was already added in image.yml
but was not used in the layout code.
|
|
Conditional Resizing with Hugo’s Image.Resize:
Image.Resize
function now runs only if an image width is defined in image.yml
, avoiding unnecessary resizing and saving processing time.Streamlined Image Management:
image.yml
, developers now have a simpler and more maintainable approach for image handling, reducing the need for repetitive coding changes.config/image.yml
:
auto
as an option for the aspect ratio, allowing images to maintain original proportions unless specified otherwise.layouts/_default/baseof.html
:
Image.Resize
conditionally, depending on specified parameters in image.yml
.config/_default/params.toml:
|
|
useRatio: bool, default true
ratio: string, defined in the image.yml
class = string, classList thumbnail image: “rounded lightbox” (“rounded” is the current default in the Hinode layout)
This changes also include the using of a lightbox:
- addEventListener click for img with the class lightbox
\assets\js\critical\functional\lightbox-script.js
.lightbox
… styles for your theme.These updates aim to:
For full technical details, refer to the commit on GitHub .
config/_default/params.toml:
|
|