class
Components::Assets::ImageAsset
- Components::Assets::ImageAsset
- Components::Assets::Asset
- Reference
- Object
Overview
Image asset with optimization capabilities
Defined in:
components/assets/base/image_asset.crConstant Summary
-
SUPPORTED_FORMATS =
["jpg", "jpeg", "png", "gif", "webp", "svg", "ico"] of ::String -
Supported image formats
Constructors
Instance Method Summary
-
#blur_placeholder : String
Generate blur placeholder (simplified)
-
#content_type : String
Abstract method - must be implemented by subclasses
-
#dimensions : Tuple(Int32, Int32) | Nil
Get image dimensions (placeholder)
- #format : String | Nil
- #format=(format : String | Nil)
- #height : Int32 | Nil
- #height=(height : Int32 | Nil)
-
#lazy_load? : Bool
Check if image should be lazy loaded
-
#picture_element(sizes : String = "100vw", loading : String = "lazy", alt : String = "", class_name : String | Nil = nil) : String
Generate picture element for responsive images
-
#process : String
Process image (optimization would happen here)
-
#responsive_set(sizes : Array(Int32)) : Hash(Int32, String)
Generate responsive image set
-
#to_data_uri : String | Nil
Convert to base64 data URI
-
#width : Int32 | Nil
Image-specific metadata
-
#width=(width : Int32 | Nil)
Image-specific metadata
Instance methods inherited from class Components::Assets::Asset
add_dependency(asset_id : String) : Nil
add_dependency,
content : String
content,
content=(content : String)
content=,
content_type : String
content_type,
dependencies : Array(String)
dependencies,
fingerprint : String
fingerprint,
get_metadata(key : String) : String | Nil
get_metadata,
id : String
id,
metadata : Hash(String, String)
metadata,
modified? : Bool
modified?,
output_filename : String
output_filename,
process : String
process,
processed_content : String
processed_content,
reload : Nil
reload,
remove_dependency(asset_id : String) : Nil
remove_dependency,
set_metadata(key : String, value : String) : Nil
set_metadata,
source_path? : String | Nil
source_path?,
to_h : Hash(String, JSON::Any)
to_h,
updated_at : Time
updated_at
Constructor methods inherited from class Components::Assets::Asset
new(source_path : String | Nil = nil, content : String = "")
new
Constructor Detail
Instance Method Detail
def content_type : String
#
Description copied from class Components::Assets::Asset
Abstract method - must be implemented by subclasses
def picture_element(sizes : String = "100vw", loading : String = "lazy", alt : String = "", class_name : String | Nil = nil) : String
#
Generate picture element for responsive images