Web Image¶
Web image helpers for downloading remote PNG and JPEG assets, caching them under the data folder, resolving registered image names, and allowing Material and DImage to load web-backed images.
Overview
lia.webimage.download(n, u, cb, flags)View Source
Purpose
Downloads a named web image, validates the URL, stores supported PNG or JPEG data under the web image cache folder, builds a material for the saved file, and updates download statistics.
Realm
Client
Parameters
string n The image cache name or save name to use for the downloaded image.
string u optional The URL to download. When omitted, the URL stored for `n` in `lia.webimage.stored` is used.
function cb optional Optional callback called with the material and cache state on success, or nil, false, and an error message on failure.
string flags optional Optional material flags used when building the cached material.
lia.webimage.register(n, u, cb, flags)View Source
Purpose
Registers a named web image URL and immediately starts downloading or loading it through the web image cache.
Realm
Client
Parameters
string n The image name used to store and retrieve the web image.
string u The HTTP or HTTPS URL for the image.
function cb optional Optional callback passed to `lia.webimage.download`.
string flags optional Optional material flags saved with the registered image and used when building its material.
lia.webimage.get(n, flags)View Source
Purpose
Returns a cached material for a registered image name, URL, or saved web image path when the file is already available locally.
Realm
Client
Parameters
string n The registered image name, mapped URL, or saved cache path to resolve.
string flags optional Optional material flags used when building the material if it is not already cached.
Returns
IMaterial|nil The cached or newly built material when the saved image exists, otherwise nil.
lia.webimage.getStats()View Source
Purpose
Returns runtime statistics for the web image cache.
Realm
Client
Returns
table A table containing `downloaded`, `stored`, and `lastReset` values.
lia.webimage.clearCache(skipReRegister)View Source
Purpose
Clears cached materials, URL mappings, and downloaded files from the web image cache folder, then optionally re-registers stored web images.
Realm
Client
Parameters
boolean skipReRegister optional Whether to skip re-registering images from `lia.webimage.stored` after clearing cached files.
Hooks
Library-specific hooks documented for this library.