A working demo of the pop-up can be found here.
I wanted a modal pop-up for images on my new Hugo site, and couldn't find one that worked with the styling that I do to the image path name.
I'm new to Hugo, but I feel that the solution is simple and effective. The close button has been optimzed for accessibility as it is named close
, but
displays only ×
(×).
The render-image.html
file goes into layouts > _default > _markdown > render-image.html
à la Hugo markup configuration.
image-modal.html
is a partial that should be placed before the closing body tag of baseof.html
or any page that you would like an
image modal.
image-modal.css
can be itegrated into the custom css file or used standalone and put into the custom css array.
Standard markdown image format should be used: ![alt text](/path/to/image.img)
.
Hashtags for css styling can also be used with image file names: ![alt text](/path/to/image.img#float-left)
. When the image is clicked,
the hash and everything to the right of the hash will be removed so the css styling doen't affect the image pop-up.
In use, click the image to po-up the modal, and click the x or the popped-up image to close the modal. That's it!