Image Client API

1.4060.0 · active · verified Tue Apr 21

The `image-client-api` package, currently at version 1.4060.0, is a specialized JavaScript library developed by Wix for generating highly optimized image URLs. Its core functionality revolves around creating canonical URLs that ensure pixel-perfect image display, minimal download latency, maximum performance, and high quality across a variety of devices and network conditions. It dynamically incorporates advanced features such as optimization for Retina displays, automatic WebP image fetching where supported by the browser, intelligent image sharpening, and machine learning-driven image upscaling. While the versioning (e.g., 1.4060.0) suggests continuous development and a rapid internal release cadence, specific public release cycles or traditional semantic versioning practices are not explicitly detailed, as it primarily serves as an internal Wix library. Its key differentiators are its deep integration with Wix's proprietary image infrastructure, leveraging advanced optimization algorithms and a streamlined API designed for consistent and performant image delivery within the Wix ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `image-client-api` and use `getScaleToFillImageUrl` to generate an optimized image URL for a specified source, target dimensions, and quality settings. It also shows how to apply this URL to an `<img>` tag.

import imageSDK from 'image-client-api';

// Create a new Image element to display the optimized image.
const img = new Image();

// Use getScaleToFillImageUrl to generate an optimized URL.
// This example scales 'some-image.jpg' from 1200x800 to fit a 640x480 container,
// potentially cropping, with a quality setting of 90 and classic upscaling.
img.src = imageSDK.getScaleToFillImageUrl(
  'some-image.jpg', // Relative URL of the image
  1200,             // Original image width
  800,              // Original image height
  640,              // Target container width
  480,              // Target container height
  { 
    quality: 90, 
    upscaleMethod: 'classic', 
    name: 'optimized-image' 
  }
);

// Append the image to the document body to see it (in a browser environment).
document.body.appendChild(img);

// Log the generated URL for inspection.
console.log('Generated Image URL:', img.src);

view raw JSON →