Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

postcss-image-sizes

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-image-sizes

PostCSS plugin to automatically get image dimensions

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

PostCSS Image Sizes Build Status

PostCSS plugin for printing image sizes in your css. It includes helpers for both retina and non-retina images.

img.my_image {
  /* Input example */
  background-size: image-width('~my_image.png') image-height('~my_image.png');
}

img.my_hidpi_image {
  /* Input example */
  background-size: hidpi-image-width('~my_image.png') hidpi-image-height('~my_image.png');
}
img.my_image {
  /* Output example */
  background-size: 100px 200px;
}

img.my_hidpi_image {
  /* Output example */
  background-size: 50px 100px;
}

Usage

const imageSizes = require('postcss-image-sizes')
postcss([imageSizes({assetsPath: '/path/to/images'})])

See PostCSS docs for examples for your environment.

Absolute and relative paths

We recommend to use absolute paths for images, since CSS has very limited support for relative paths. Path is treated as absolute, when it is prefixed with ~ or / sign. You need to specify assetsPath option to use those absolute paths (see below).

All other paths will be treated as relative (to current file).

Configuration options

assetsPath — absolute path, against which images paths will be resolved.

Keywords

FAQs

Package last updated on 27 Feb 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc