1.0.13 • Published 7 years ago

lasso-image v1.0.13

Weekly downloads
48
License
Apache License v2...
Repository
github
Last release
7 years ago

lasso-image

This module provides a plugin for the Lasso.js and a JavaScript API that allows image info (URL, width and height) to be retrieved on both the server and the client.

Installation

Install the plugin:

npm install lasso-image --save

Enable the plugin:

require('lasso').configure({
    plugins: [
        'lasso-image',
        ...
    ]
})

Usage

The following code can be used to get image info (URL, width and height) on both the server and the client:

var lassoImage = require('lasso-image');
lassoImage.getImageInfo(require.resolve('./my-image.png'), function(err, imageInfo) {
    if (err) {
        // Handle the error
    }

    console.log('URL: ', imageInfo.url);
    console.log('width: ', imageInfo.width);
    console.log('height: ', imageInfo.height);
});

Referenced images will automatically be bundled and written and the URL for the bundled image will be returned. The result is cached (on the server) so there is no performance penalty in making subsequent calls for the same image path.

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago