Skip to content

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

The web image library centralizes clientside image loading under `lia.webimage`. It validates HTTP and HTTPS image URLs, downloads supported image formats into `data/lilia/webimages/`, caches built materials, maps URLs to stored image names, and integrates those cached assets with `Material` and `DImage:SetImage`.

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.


WebImageDownloaded(name, path)View Source

Purpose

Runs after a web image is successfully downloaded, saved, and built into a material.

Realm

Client

Parameters

string name The registered image name or derived save name used by the web image cache.

string path The data material path for the downloaded image, prefixed with `data/`.