Image Component

Web HTML facilitates a wide-varieties of displaying images using various image tags like <img>, <amp-img> and <picture> in their respective outputs. Bissetii supports them seemlessly in their respective outputs.

This component is available starting from v1.11.0.

Hugo

Bissetii prepared some Hugo interfaces to generate image seamlessly across all output formats.

Shortcodes

By default, it is hard to process images across multiple outputs while maintaining a single input format. Hence, Bissetii prepared the following shortcodes to standardize the image rendering input. These shortcodes are specific to Bissetii which is working differently from Hugo.

image Shortcode

image shortcode is a quick-and-easy image insertion. It does not require any data file configurations. Depending on Bissetii version, image shortcode may behaves differently.

Version v1.13.0 and Above

The shortcode complies to the following pattern:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{{< image [ALT]
	[URL]
	[WIDTH]
	[HEIGHT]
	[ISMAP]
	[LOADING]
	[SRCSET]
	[LAYOUT]
	[CLASS]
	[SIZES] >}}
  1. CLASS - OPTIONAL
    1. Specify the CSS class= attribute.
  2. SIZES - OPTIONAL.
    1. Specify the responsive image sizes (sizes=). This field is automatically removed if SRCSET is empty.

To use it, simply call it inside the markdown. Example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
{{< image "My Portrait" "/img/me/portrait.png" "200" "400"
	"false" "lazy" "/img/me/portrait-2x.png 2x, /img/me/portrait-3x.png 3x"
	"responsive-amp-only" "id-img-portrait"
	"(min-width: 640px) 2x" "John Smith" >}}

		⥥



<img alt="My Portrait"
	src="https://bissetii.zoralab.com/img/me/portrait.png"
	class="id-img-portrait"
	width="200"
	height="400"
	srcset="https://bissetii.zoralab.com/img/me/portrait-2x.png 2x,https://bissetii.zoralab.com/img/me/portrait-3x.png 3x"
	sizes="(max-width: 640px) 2x, (min-width: 641px) 3x"
	loading="lazy"/>

Version v1.12.5 and Below

The shortcode complies to the following pattern:

1
2
3
4
5
6
7
8
9
{{< image [ALT]
	[URL]
	[WIDTH]
	[HEIGHT]
	[ISMAP]
	[LOADING]
	[SRCSET]
	[LAYOUT]
	[CLASS] >}}
  1. CLASS - OPTIONAL
    1. Specify the CSS class= attribute.

picture Shortcode

For images requiring the use of <picture> tag in Vanilla HTML5 and using data file to organize the image data (as opposed to image shortcode), Bissetii supplied picture shortcode for the job.

Version v1.13.0 and Above

The shortcode complies to the following pattern:

{{< picture [DATASET_PATH]  >}}
Data File Structure

The data file shall be stored inside your Hugo data/ directory stated inside your configuration file. The file structure is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[IMG01]
IsMap = false
LoadingMode = "lazy"
Class = "my-class"
URL = "/img/bg/img_placeholder.svg"
Width = "400"
Height = "300"
Layout = "responsive-amp-only"
SrcList = """
/img/bg/img_480w.svg 480w,
/img/bg/img_800w.svg 800w,
/img/bg/img_1024w.svg 1024w,
/img/bg/img_2048w.svg 2048w,
/img/bg/img_4096w.svg 4096w
"""
Sizes = """
(max-width: 480px) 480px,
(max-width: 800px) 800px,
(max-width: 1024px) 1024px,
(max-width: 2048px) 2048px,
(min-width: 2049px) 4096px
"""

[IMG01.AltText]
en = "picture elements"
zh-hans = "图画元素"




# Picture Source HTML Tag
[IMG01.Sources.01]
Type = "image/svg+xml"
SourceSet = """
/img/bg/img_800w.svg 1x,
/img/bg/img_1024w.svg 2x,
/img/bg/img_2048w.svg 3x
"""
Media = "(max-width: 20em)"

[IMG01.Sources.02]
Type = "image/svg+xml"
SourceSet = """
/img/bg/img_800w.svg 1x,
/img/bg/img_1024w.svg 2x,
/img/bg/img_2048w.svg 3x
"""
Media = "(max-width: 40em)"

Calling the shortcode against the data file above yields:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<picture>
		<source srcset="https://bissetii.zoralab.com/img/bg/img_800w.svg 1x,https://bissetii.zoralab.com/img/bg/img_1024w.svg 2x,https://bissetii.zoralab.com/img/bg/img_2048w.svg 3x" media="(min-width: 20em)" type="image/svg&#43;xml">
		<source srcset="https://bissetii.zoralab.com/img/bg/img_800w.svg 1x,https://bissetii.zoralab.com/img/bg/img_1024w.svg 2x,https://bissetii.zoralab.com/img/bg/img_2048w.svg 3x" media="(min-width: 40em)" type="image/svg&#43;xml">

<img alt="picture elements"
	src="https://bissetii.zoralab.com/img/bg/img_placeholder.svg"
	class="my-class"
	width="400"
	height="300"
	loading="lazy"/>
</picture>

Go

Coming Soon.

HTML

Bissetii supports the <img> and <amp-img> seamlessly and accordingly based on their respective output formats. Additionally, starting from version v1.13.0, <picture> tag for non-AMPHTML output format is now available.

Basic Image Inclusion

To cater responsive images, Bissetii recommends the following HTML codes for quick and easy usage.

Vanilla HTML5

For vanilla HTML5, the basic image inclusion example would be:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<img alt="image srcset with sizes"
	src="https://bissetii.zoralab.com/img/bg/img_480w.svg"
	srcset="https://bissetii.zoralab.com/img/bg/img_480w.svg 480w,
		https://bissetii.zoralab.com/img/bg/img_800w.svg 800w,
		https://bissetii.zoralab.com/img/bg/img_1024w.svg 1024w,
		https://bissetii.zoralab.com/img/bg/img_2048w.svg 2048w,
		https://bissetii.zoralab.com/img/bg/img_4096w.svg 4096w"
	sizes="(max-width: 480px) 480px,(max-width: 800px) 800px,(min-width: 801px) 4096px"
	width="200"
	height="150"
	loading="lazy"
/>

AMPHTML

For AMPHTML, the basic image inclusion example would be:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
<amp-img alt="image title/purpose"
	src="https://bissetii.zoralab.com/en/img/bg/img_placeholder.svg"
	srcset="https://bissetii.zoralab.com/en/img/bg/img_480w.svg 480w,
		https://bissetii.zoralab.com/en/img/bg/img_800w.svg 800w,
		https://bissetii.zoralab.com/en/img/bg/img_1024w.svg 1024w,
		https://bissetii.zoralab.com/en/img/bg/img_2048w.svg 2048w,
		https://bissetii.zoralab.com/en/img/bg/img_4096w.svg 4096w"
	sizes="(max-width: 480px) 480px,(max-width: 800px) 800px,(min-width: 801px) 4096px"
	width="200"
	height="150"
	layout="responsive">
</amp-img>

The main difference is the use of its custom <amp-img> AMPHTML tag instead of the conventional <img> HTML tag. Also, it has a tailing close tag (</amp-img>).

Please keep in mind that <amp-img> is always being lazy-loaded.

Art-Directed Image Inclusion

Sometimes, the image needs to be art-directed where small screen should be presented with other images or cropped version of the original image (which is a completely different image). Bissetii recommends the following HTML implementations based on your output formats.

Vanilla HTML5

For vanilla HTML5, it is highly recommended to use <picture> HTML tag alongside its <source> child HTML tag. The reason is to keep the HTML codes sane and maintainable where each sources can be detailed easily in its own HTML line. Although srcset and sizes can do the same job, it would be insane to stuff too many things inside them.

Here is an example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<picture>
	<source srcset="//holloway-seraphim:8080/img/bg/img_800w.jpg 1x,
		//holloway-seraphim:8080/img/bg/img_1024w.jpg 2x,
		//holloway-seraphim:8080/img/bg/img_2048w.jpg 3x"
		type="image/jpeg"
		media="(max-width: 20em)" type="image/svg&#43;xml">
	<source srcset="//holloway-seraphim:8080/img/bg/img_1x.png 1x,
		//holloway-seraphim:8080/img/bg/img_2x.png 2x,
		//holloway-seraphim:8080/img/bg/img_3x.png 3x"
		type="image/png"
		media="(max-width: 40em)" type="image/svg&#43;xml">
	<img alt="picture elements"
		src="//holloway-seraphim:8080/img/bg/img_placeholder.svg"
		width="400"
		height="300"
		loading="lazy"/>
</picture>

Some noticable changes would be:

  1. Each sources now has its own srcset, media, and even file type changes.
    1. Use the srcset to supply multiple image sources (e.g. different resolution).
    2. Use media to set the rules of applications (e.g. usually max-width).
    3. The type must be a compliant MIME type value. E.g. image/jpeg and not image/jpg.
  2. You no longer need to specify srcset and sizes for the fallback img tag. It makes no sense to cause confusion between the 2.
  3. You can define more sources and let the browser to the best selection accordingly.

AMPHTML

Currently, there is no way to specify multiple sources for art-directing image display. You will need to compile the final value and stuff it inside the existing srcset and sizes respectively.

CSS

This section covers all the CSS part for Image component. Please go through each sub-section carefully as they affects Bissetii styling directly.

This CSS section is ONLY AVAILABLE starting from version v1.13.0 and above.

CSS Variables

Bissetii provided a list of CSS variables dedicated for image styling alternation without needing to recompile Sass. These variables are best applied directly to the image HTML tag. Example:

<img src="..." alt="..." style="--image-max-width: 450px;">
<amp-img src="..." alt="..." style="--image-max-width: 450px;" ... ></amp-img>

To set it globally, the variables can be applied to the <body> tag. Example:

<body style="--image-max-width: 30vw" ...>

--image-max-width

Affects the image max width. The value must be compliant to max-width: CSS field. Default is 100%.

--image-max-height

Affects the image max height. The value must be compliant to max-width: CSS field. Default is unset.

--image-height

Affects the image immediate height. The value must be compliant to height: CSS field. Default is auto.

--image-filter

Affects the image overlaying effect. The value must be compliant to filter: CSS field. Default is unset.

--image-border

Affects the image border. The value must be compliant to border: CSS field. Default is none.

--image-border-radius

Affects the image border radius (or roundness corder). The value must be compliant with border-radius: CSS field. Default is 0.

--image-animation

Affects the image CSS animation. The value must be compliant with animation: CSS field. Default is unset.

Javascript Parts

This component does not rely on any Javascript.

Sass

Depending on release version, the Sass files work differently. Bissetii does not package Sass codes explictly so please view them via the git repository.

v1.13.0 and Above

Bissetii uses Dart Sass to compile the styling Sass codes into CSS file. This component’s Sass codes is available at the following location:

pkg/components/internal/image

v1.12.5 and Before

The Sass scripts responsible for styling image are located at:

assets/css/bissetii/modules/core/_Image.scss

Researches

Here are the researches done to ensure Image component meets the necessarily quality assurances:

  1. Image Web User Interface Architectural Design Analysis (https://doi.org/10.5281/zenodo.4925642)

Epilogue

That is all about Image component in Bissetii. If you need more feature or encountered a bug, Please feel free to contact us by filling an issue ticket at our Issue Section. We will be glad to help you.