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:
|
|
ALT
- COMPULSORY- The image alternate text (
alt=
).
- The image alternate text (
URL
- COMPULSORY- The fallback image URL source (
src=
). Bissetii’s compatible relative URL is allowed and shall be processed into absolute URL as the final output.
- The fallback image URL source (
WIDTH
- COMPULSORY- The width of the image (
width=
). It is compulsory because some output formats has strict rule for it.
- The width of the image (
HEIGHT
- COMPULSORY- Height of the image (
height=
). It is compulsory because some output formats has strict rule for it.
- Height of the image (
ISMAP
- OPTIONAL- Specify the image is mapped under an anchor hyperlink. To disable it,
simply supply an empty string (
""
).
- Specify the image is mapped under an anchor hyperlink. To disable it,
simply supply an empty string (
LOADING
- OPTIONAL- The image
loading=
attribute. It ONLY acceptseager
orlazy
.
- The image
SRCSET
- OPTIONAL- Specify the image’s source URL set (
srcset=
). The value shall be the final compiled long string version. To disable it, simply supply an empty string (""
).
- Specify the image’s source URL set (
LAYOUT
- COMPULSORY- Specify the image layout using Bissetii’s values. There are 4 types:
responsive
- ensures the image is always responsive.responsive-amp-only
- ensures the responsiveness only applies to AMPHTML output format.responsive-height-only
- ensures the responsiveness only applies to height. For Vanilla HTML5,width=
attribute is retained whileheight=
attribute is removed even when it is a valid value.responsive-width-only
- ensures the responsiveness only applies to the height. For Vanilla HTML5,height=
attribute is retained whilewidth=
attribute is removed even when it is a valid value.
- Specify the image layout using Bissetii’s values. There are 4 types:
CLASS
- OPTIONAL- Specify the CSS
class=
attribute.
- Specify the CSS
SIZES
- OPTIONAL.- Specify the responsive image sizes (
sizes=
). This field is automatically removed ifSRCSET
is empty.
- Specify the responsive image sizes (
To use it, simply call it inside the markdown. Example:
|
|
Version v1.12.5
and Below
The shortcode complies to the following pattern:
|
|
ALT
- COMPULSORY- The image alternate text (
alt=
).
- The image alternate text (
URL
- COMPULSORY- The fallback image URL source (
src=
). Bissetii’s compatible relative URL is allowed and shall be processed into absolute URL as the final output.
- The fallback image URL source (
WIDTH
- COMPULSORY- The width of the image (
width=
). It is compulsory because some output formats has strict rule for it.
- The width of the image (
HEIGHT
- COMPULSORY- Height of the image (
height=
). It is compulsory because some output formats has strict rule for it.
- Height of the image (
ISMAP
- OPTIONAL- Specify the image is mapped under an anchor hyperlink. To disable it,
simply supply an empty string (
""
).
- Specify the image is mapped under an anchor hyperlink. To disable it,
simply supply an empty string (
LOADING
- OPTIONAL- The image
loading=
attribute. It ONLY acceptseager
orlazy
.
- The image
SRCSET
- OPTIONAL- Specify the image’s source URL set (
srcset=
). The value shall be the final compiled long string version. To disable it, simply supply an empty string (""
).
- Specify the image’s source URL set (
LAYOUT
- COMPULSORY- Specify the image layout using Bissetii’s values. There are 4 types:
responsive
- ensures the image is always responsive.responsive-amp-only
- ensures the responsiveness only applies to AMPHTML output format.responsive-height-only
- ensures the responsiveness only applies to height. For Vanilla HTML5,width=
attribute is retained whileheight=
attribute is removed even when it is a valid value.responsive-width-only
- ensures the responsiveness only applies to the height. For Vanilla HTML5,height=
attribute is retained whilewidth=
attribute is removed even when it is a valid value.
- Specify the image layout using Bissetii’s values. There are 4 types:
CLASS
- OPTIONAL- Specify the CSS
class=
attribute.
- Specify the CSS
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] >}}
DATASET_PATH
- COMPULSORY- The Hugo data pathing to the image data set.
- For example, if the data file is located in
data/pictures/myAlbum.toml
where the data directory is calleddata/
and the dataset isIMG01
, the Hugo data pathing shall be:pictures.myAlbum.IMG01
.
- For example, if the data file is located in
- The Hugo data pathing to the image data set.
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:
|
|
Calling the shortcode against the data file above yields:
|
|
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:
|
|
alt=
- COMPULSORYalt
text for describing the image when the image fails to load and to allow a search engine bot to comprehend the image.
src=
- COMPULSORY- the fallback version of the image URL.
srcset=
- OPTIONAL- the responsive image URL sources and their configurations. Best use
would be the image width or resolution (e.g.
1x
,2x
). The browser will comprehend the last and only download the one that is making sense.
- the responsive image URL sources and their configurations. Best use
would be the image width or resolution (e.g.
sizes=
- OPTIONAL- setting the rules of selecting an appropriate image using media
query. It works closely with
srcset
attribute as its source of image URL and image conditions. - It shall only exist when
srcset=
is available.
- setting the rules of selecting an appropriate image using media
query. It works closely with
width=
- OPTIONAL- the width of the image you plan to display in
px
unit. It’s recommended to state the attribute for spacing allocation consistency purposes.
- the width of the image you plan to display in
height=
- OPTIONAL- the height of the image you plan to display in
px
unit. It’s recommended to state the attribute for spacing allocation consistency purposes.
- the height of the image you plan to display in
loading=
- OPTIONAL - the image loading instruction. Setting the value tolazy
allows user to only load the image when it enters view port. This is useful for saving download bandwidth during bad connectivity.
AMPHTML
For AMPHTML, the basic image inclusion example would be:
|
|
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>
).
alt=
- COMPULSORYalt
text is for describing the image when the image fails to load and to allow a search engine bot to comprehend the image.
src=
- COMPULSORY- the fallback version of the image URL.
srcset=
- OPTIONAL- the responsive image URL sources and their configurations. Best use
would be the image width or resolution (e.g.
1x
,2x
). The browser will comprehend the last and only download the one that is making sense.
- the responsive image URL sources and their configurations. Best use
would be the image width or resolution (e.g.
sizes=
- OPTIONAL- setting the rules of selecting an appropriate image using media
query. It works closely with
srcset
attribute as its source of image URL and image conditions. - It shall only exist when
srcset=
is available.
- setting the rules of selecting an appropriate image using media
query. It works closely with
width=
- OPTIONAL- the width of the image you plan to display in
px
unit. It’s recommended to state the attribute for spacing allocation consistency purposes.
- the width of the image you plan to display in
height=
- OPTIONAL- the height of the image you plan to display in
px
unit. It’s recommended to state the attribute for spacing allocation consistency purposes.
- the height of the image you plan to display in
layout=
- OPTIONAL- the AMP layout instruction. Setting the value to
responsive
will set the image size to resize based on the screen size automatically.
- the AMP layout instruction. Setting the value to
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:
|
|
Some noticable changes would be:
- Each sources now has its own
srcset
,media
, and even filetype
changes.- Use the
srcset
to supply multiple image sources (e.g. different resolution). - Use
media
to set the rules of applications (e.g. usuallymax-width
). - The
type
must be a compliant MIME type value. E.g.image/jpeg
and notimage/jpg
.
- Use the
- You no longer need to specify
srcset
andsizes
for the fallbackimg
tag. It makes no sense to cause confusion between the 2. - 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:
- 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.