New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

visionary-image

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

visionary-image

React image component with built-in Blurhash placeholders for better UX and Core Web Vitals.

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
0
Created
Source

Visionary Image

React image component with built-in Blurhash placeholders for better UX and Core Web Vitals.

GitHub Release GitHub Actions Workflow Status npm package size (minzipped, via Bundlephobia) NPM Downloads Storybook demo

Features

Lighthouse Performance

Lighthouse report filmstrip showing three-layer image loading process Lighthouse report loading stage filmstrip

Installation

Install via npm, yarn, or pnpm.

npm install --save visionary-image

Usage

Begin by creating a Visionary image URL. This is then passed to the src prop of the Image component.

Creating a Visionary Image URL

There are several ways to create a Visionary URL.

Render Image

import { Image } from "visionary-image";

const ImageDetails = () => <Image alt="..." src="<Visionary URL>" />;

Component Props

NameDescription
alt
string
Image alt tag. Adding alt text to images is highly recommended to accommodate accessible devices and improve discoverability.
bgColorAlpha
number
Base layer (background color) alpha channel.
Default: 0.7
className
string
Classname applied to the container div or the fallback img element.
debug
boolean
Prints handy debug info to the console (Visionary URL data, render times).
disableBlurLayer
boolean
Disables rendering of the blur (canvas) layer.
disableImageLayer
boolean
Disables rendering of the image layer.
height
number, string
If set, will override internally computed image height. By default, Visionary renders optimally sized images, using the aspect-ratio and max-width placeholder data.
hideImageLayer
boolean
Hides the image layer, revealing the blur layer underneath.
lazy
boolean
Should image load lazily.
Default: true
onClick
function
Callback function to invoke when the image is clicked. function.
onError
function
Error callback function.
onLoad
function
Image loaded callback function.
preventDrag
boolean
Prevents user from dragging the image element.
preventSelection
boolean
Prevents user from highlighting the image element.
punch
number
Blurhash punch parameter.
Default: 1
src
string
Visionary URL, Visionary Code, or ordinary image URL.
If src contains Visionary data, placeholders will be rendered, otherwise falls back to an img element.
required
width
number, string
If set, will override internally computed image width. By default, Visionary renders optimally sized images, using the aspect-ratio and max-width placeholder data.

Relevant Questions

Do image placeholders render server-side?

Yes, Visionary Image supports server-side rendering (SSR) and static site generation (SSG), as well as client-side rendering. In server-rendered scenarios, the first layer (background color) renders immediately, followed by the Blurhash and image layers once the page loads in the client's browser.

How long does the Blurhash canvas take to load?

Canvas operations are highly efficient in modern browsers. Rendering the 24x24 pixel Blurhash placeholder typically takes around 1ms.

What is Blurhash and where can I learn more?

Blurhash uses Discrete Cosine Transforms to represent a color-accurate image placeholder as a compact string (in 20-30 characters). Check out the official Blurhash docs for more info.

Keywords

blurhash

FAQs

Package last updated on 01 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts