Adaptive is a tool which allow Filestack users to combine the power of on-the-fly image processing with the latest standard for responsive web images.
This library ships with a built-in virtual DOM adapter powered by hyperx, which allows you to simply call picture(source, options, renderer), where renderer can be any DOM builder supported by hyperx (e.g React.createElement). If renderer is not provided then picture will default to returning plain DOM.
$3
- Focus on usability and performance - Works with Filestack handles, storage aliases and external urls - Support for different sizes and formats in srcSet - Allows you to add some image transformations - Easily integrable with external virtual DOM renderers
Usage
$3
You can find the newest version at https://static.filestackapi.com/adaptive/1.3.0/adaptive.min.js
` #### SRI Subresource Integrity (SRI) is a security feature that enables browsers to verify that files they fetch (for example, from a CDN) are delivered without unexpected manipulation. It works by allowing you to provide a cryptographic hash that a fetched file must match
To obtain sri hashes for adaptive library check manifest.json file on CDN:
` #### Use with JSX In a case of need to create your own element you can call makePictureTree directly in your JSX `js import React, { Component } from 'react'; import { makePictureTree } from 'filestack-adaptive';
WebP can be used when it's supported by the browser. Filestack will take care of the image conversion and cache it on the delivery network for future requests.
`html ` #### Disable validator To speed up generating of final output (useful when you have a bunch of images on your site) you can optionally disable validation of transformation params by passing additional prop in options: `js const options = { ... useValidator: false, ... } `
Development
To install and work on Adaptiv locally: `bash git clone git@github.com:filestack/adaptive.git cd adaptive npm install ` To create build directory: ` npm run build ` This newly created directory contains `text build/ ├── browser/ # for the UMD module (usable in HTML script tags) └── index.umd.js # ├── main/ # for the CommonJS module ├── ... # └── index.js # └── module/ # for the ES Module (suitable for bundlers like Webpack and Rollup) ├── ... # └── index.js # `
Documentation
For more info about available methods and options check browser documentation:
https://filestack.github.io/adaptive/
Contributing
We follow the conventional commits specification to ensure consistent commit messages and changelog formatting.
Future
Adaptive is joining an ecosystem already populated with many utilities for responsive images. We want to remain flexible while still having some opinions on how to implement picture elements using Filestack conversions, and we know it is hard to cover every use case. Contributions and ideas are welcome that would help improve the usefulness of this library.
Current ideas:
* LQIP using the Filestack blur transformation * Compress HiDPI images using Filestack compress task * Implement art direction with Filestack crop * Develop a PostHTML transform for post-processing HTML using