getPropertyFileUrl
Builds a URL the wallpaper webview can use to load a local file referenced by an image / file property value. The Fluxlay desktop app serves the file via GET /v1/file, restricted to paths currently assigned to an image / file property of the active wallpaper.
Import
import { getPropertyFileUrl } from "@fluxlay/react";Signature
function getPropertyFileUrl(path: string | null | undefined): string | null;Parameters
| Argument | Type | Description |
|---|---|---|
path | string | null | undefined | Property value returned by useProperties() for an image / file property. |
Return value
A URL string usable with <img src> / <video src> / <audio src> etc. Returns null when path is empty / null / undefined.
Usage
import { getPropertyFileUrl, useProperties } from "@fluxlay/react";
function Wallpaper() {
const { customLogo } = useProperties<{ customLogo: string | null }>();
const url = getPropertyFileUrl(customLogo);
return url ? <img src={url} alt="logo" /> : null;
}Notes
- The returned URL is of the form
http://127.0.0.1:<port>/v1/file?window_label=<label>&path=<path>, inheritingfluxlay_portandwindow_labelfrom the current page query string. - The backend only serves paths currently assigned to one of this wallpaper's
image/fileproperties. Passing arbitrary paths returns 403. - When the wallpaper runs outside the Fluxlay desktop app (e.g. a standalone web preview), the URL can still be constructed but the actual fetch will fail because the local backend is not reachable.