Adding the width
and height
attribute to all images to use these values with available gallery libraries.
When using the gallery card the resulting HTML code of each of the img
tags include a width
and height
attribute, which shows information about the original size of each image.
For example (gallery with one image):
<figure class="kg-card kg-gallery-card kg-width-wide">
<div class="kg-gallery-container">
<div class="kg-gallery-row">
<div class="kg-gallery-image" style="flex: 1.67371 1 0%;">
<img src="http://192.168.178.39:2368/content/images/2020/10/1-1.png"
width="1267"
height="757"
alt=""
srcset="http://192.168.178.39:2368/content/images/size/w600/2020/10/1-1.png 600w,
http://192.168.178.39:2368/content/images/size/w1000/2020/10/1-1.png 1000w,
http://192.168.178.39:2368/content/images/2020/10/1-1.png 1267w"
sizes="(min-width: 1200px) 1200px">
</div>
</div>
</div>
</figure>
When using the “classical single image” card the resulting img
tag is missing this information.
Using the image card:
<figure class="kg-card kg-image-card">
<img src="http://192.168.178.39:2368/content/images/2020/10/1.png"
class="kg-image"
alt=""
srcset="http://192.168.178.39:2368/content/images/size/w600/2020/10/1.png 600w,
http://192.168.178.39:2368/content/images/size/w1000/2020/10/1.png 1000w,
http://192.168.178.39:2368/content/images/2020/10/1.png 1267w"
sizes="(min-width: 720px) 720px">
</figure>
From the srcset
you can get the width of the original image, but not the height.
Unfortunately this is a necessary information to use the PhotoSwipe library, as seen here or in the “Getting started” guide.