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

ArgumentTypeDescription
pathstring | null | undefinedProperty 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>, inheriting fluxlay_port and window_label from the current page query string.
  • The backend only serves paths currently assigned to one of this wallpaper's image / file properties. 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.