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

svelte-imgix

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-imgix

Responsive, lazily loaded images with Svelte and Imgix

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Svelte Imgix

Responsive, lazily-loaded images with Svelte and Imgix

Features

  • Lazy loading with automatic LQIP placeholders
  • Generate responsive image srcsets automatically

Basic Usage

npm i svelte-imgix
<script>
  import Imgix from 'svelte-imgix';
</script>

<Imgix
  src="https://assets.imgix.com/image.jpg"
/>
Svelte-preprocess

svelte-meta is written in Typescript, and requires Svelte's preprocessing to be enabled. If you're using Sapper this comes enabled by default.

To enable preprocessing, install svelte-preprocess and include it in the svelte config in your rollup.config.js or webpack.config.js

npm i svelte-preprocess
import autoPreprocess from 'svelte-preprocess';

svelte({
  preprocess: autoPreprocess()
});

See the svelte-preprocess docs for more.

Adding Sizes

Svelte-Imgix automatically generates a responsive srcset for a huge range of viewport sizes. By adding a sizes attribute to your image you can instruct the browser to use the appropriate source based on media queries.

See the MDN article on responsive images for a thorough walkthrough.

Setting Imgix Parameters

You can either provide a full Imgix URL (with query parameters) to svelte-imgix, or define parameters to override anything set on the src with the imgixParams prop. All valid Imgix properties are avaiable.

<Imgix
  src="https://assets.imgix.com/image.jpg"
  imgixParams={{
    auto: 'format',
    fit: 'facearea'
  }}
/>

Properties

PropertyDescription
srcImgix source of the image
altAlt text for the image
ImgixParamsObject of Imgix parameters to set on the image, overrides any defaults given in src

Keywords

FAQs

Package last updated on 16 Nov 2020

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