Struct manganis::ImageAssetBuilder
source · pub struct ImageAssetBuilder;
Expand description
A builder for an image asset. This must be used in the mg!
macro.
Note: This will do nothing outside of the
mg!
macro
Implementations§
source§impl ImageAssetBuilder
impl ImageAssetBuilder
sourcepub const fn format(self, format: ImageType) -> Self
pub const fn format(self, format: ImageType) -> Self
Sets the format of the image
Note: This will do nothing outside of the
mg!
macro
The choosing the right format can make your site load much faster. Webp and avif images tend to be a good default for most images
const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").format(ImageType::Webp));
sourcepub const fn size(self, x: u32, y: u32) -> Self
pub const fn size(self, x: u32, y: u32) -> Self
Sets the size of the image
Note: This will do nothing outside of the
mg!
macro
If you only use the image in one place, you can set the size of the image to the size it will be displayed at. This will make the image load faster
const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").size(512, 512));
sourcepub const fn low_quality_preview(self) -> Self
pub const fn low_quality_preview(self) -> Self
Make the image use a low quality preview
Note: This will do nothing outside of the
mg!
macro
A low quality preview is a small version of the image that will load faster. This is useful for large images on mobile devices that may take longer to load
const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").low_quality_preview());
sourcepub const fn preload(self) -> Self
pub const fn preload(self) -> Self
Make the image preloaded
Note: This will do nothing outside of the
mg!
macro
Preloading an image will make the image start to load as soon as possible. This is useful for images that will be displayed soon after the page loads or images that may not be visible immediately, but should start loading sooner
const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").preload());
sourcepub const fn url_encoded(self) -> Self
pub const fn url_encoded(self) -> Self
Make the image URL encoded
Note: This will do nothing outside of the
mg!
macro
URL encoding an image inlines the data of the image into the URL. This is useful for small images that should load as soon as the html is parsed
const _: &str = manganis::mg!(image("https://avatars.githubusercontent.com/u/79236386?s=48&v=4").url_encoded());