Git Product home page Git Product logo

intervention-request-js's Introduction

Built With Stencil

Intervention Request JS

Web component for building HTML picture tags using Intervention Request images

Installation

From npm registry

yarn add @rezo-zero/intervention-request

or

npm install @rezo-zero/intervention-request

Framework integration

See details on StencilJS documentation

Usage

<intervention-request
    src="folder/filename.jpg"
    alt="My sample image"
    baseUrl="https://intervention-request.test"
    width="1280"
    height="768"
    formats='{
         "width": 1024,
         "height": 768,
         "media": [
             {"srcset":[{"format":{"fit":"1920x980","quality":80},"rule":"1x"}, {"format":{"fit":"3840x1960","quality":80},"rule":"2x"}], "rule":"(min-width: 1280px)"},
             {"srcset":[{"format":{"fit":"768x320","quality":80},"rule":"1x"}], "rule":"(min-width: 768px)"},
             {"srcset":[{"format":{"fit":"400x280","quality":80},"rule":"1x"}]}
         ]
     }'>
</intervention-request>

Attributes

See all available components attributes here

Styling

CSS variables applied to image

:root {
    --ir-object-fit: fill;
    --ir-object-position: inherit;
    --ir-width: 100%;
    --ir-height: auto;
}

Global configurations & overrides

A common configuration can be defined via the global variable interventionRequestJS as follows

/**
 * Override intervention request default configurations
 * @type InterventionRequestConfigurations
 */
window.interventionRequestJS = {
    /**
     * Enable debug mode
     */
    debug: true,

    /**
     * Default strategy
     * Applied on each element without strategy props provided
     */
    strategy: 'default',

    /**
     * Default loading typee
     */
    loading: 'lazy',

    /**
     * Strategies config overrides
     */
    strategies: {
        default: { baseUrl: 'http://intervention.local/assets' },
        cloudinary: { baseUrl: 'https://res.cloudinary.com/demo/image/upload' }

        /**
         * New strategy can be added here
         * @type InterventionRequestStrategy
         */
    },

    /**
     * Default media options
     * Applied on every media if no props override provided
     */
    mediaOptions: {
        quality: 100,
        progressive: 0
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.