Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
grunt-responsive-images
Advanced tools
Produces images at different sizes
This plugin requires Grunt ~0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-responsive-images --save-dev
You'll also need to install Imagemagick CLI Tools.
brew install ImageMagick
Once both the plugin and ImageMagick have been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-responsive-images');
The responsive_images task will take your source image and create images at different resolutions for use with PictureFill or with srcset.
A demo of both srcset and PictureFill using Grunt Responsive Images is available here.
Some slides about the plugin are available here.
In your project's Gruntfile, add a section named responsive_images
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
responsive_images: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
},
},
})
Type: Array
Default value:
[{
name: "small",
width: 320,
height: 240,
quality: 1
},{
name: "medium",
width: 640,
height: 480,
quality: 1
},{
name: "large",
width: 1024,
height: 768,
quality: 1
}]
An array of objects containing the sizes we want to resize our image to.
If both width and height are specified, then the image will be resized and cropped.
If a name
is specified, then the file will be suffixed with this name. e.g. my-image-small.jpg
If a name
is not specified, then the file will be suffixed with the width and/or height. e.g. my-image-320x240.jpg
Use suffix
for retina graphic filenames. e.g. my-image-320x240_x2.jpg
Use quality
to change the quality of an image (0.1, 0.2 ... 0.9, 1).
Type: String
Default value: -
The character used to separate the image filename from the size name.
Using the default options will produce 3 responsive images - one at 320px wide, one at 640px wide and one at 1024px wide.
grunt.initConfig({
responsive_images: {
myTask: {
options: {},
files: {
'dest/mario-yoshi.jpg': 'test/assets/mario-yoshi.jpg'
}
}
}
})
In this example, we specify our own image sizes, including a retina graphic. We also specify our files with a wildcard.
grunt.initConfig({
responsive_images: {
myTask: {
options: {
sizes: [{
width: 320,
height: 240
},{
name: 'large',
width: 640
},{
name: "large",
width: 1024,
suffix: "_x2",
quality: 0.6
}]
},
files: [{
expand: true,
src: ['assets/**.{jpg,gif,png}'],
cwd: 'test/',
dest: 'tmp/'
}]
}
},
})
If you would like to output each image size to a different directory, you can do so with custom_dest. For example:
grunt.initConfig({
responsive_images: {
myTask: {
options: {
sizes: [{
width: 320,
},{
width: 640,
},{
width: 1024,
}]
},
files: [{
expand: true,
src: ['**.{jpg,gif,png}'],
cwd: 'test/assets/custom_dest/',
custom_dest: 'tmp/custom_dest/{%= width %}/'
}]
}
},
})
You can use {%= width %}
, {%= height %}
, {%= name %}
or {%= path %}
as a delimiter.
Please note that {%= width %}
, {%= height %}
and {%= name %}
are only available if they are set in the object literal that you use to set each generated size option.
The {%= path %}
value contains additional directory structure from the current working directory (cwd in files array) to each image. Using {%= path %}
allows any complex directory structure to persist into the rendered responsive images directory.
NOTE: for grunt-responsive-images to pick up images within subdirectories you must set your files.src property to **/*.{jpg,gif,png}
.
The following sites and libraries are using Grunt Responsive Images (because they ROCK!):
And the inspiration for grunt-responsive-videos.
Please let us know if your live site or library uses Grunt Responsive Images. We'll add our favorites.
fatal error: spawn ENOENT
- Ensure Imagemagick CLI tools are installed. Try uninstalling and reinstalling them if you are having issues.In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
FAQs
Produce images at different sizes for responsive websites.
The npm package grunt-responsive-images receives a total of 204 weekly downloads. As such, grunt-responsive-images popularity was classified as not popular.
We found that grunt-responsive-images demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.