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

@sanity/image-url

Package Overview
Dependencies
Maintainers
0
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/image-url

Tools to generate image urls from Sanity content

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
241K
increased by9.91%
Maintainers
0
Weekly downloads
 
Created

What is @sanity/image-url?

@sanity/image-url is a JavaScript client for generating URLs for images stored in Sanity's content lake. It allows you to build image URLs with various transformations such as resizing, cropping, and format conversion.

What are @sanity/image-url's main functionalities?

Basic URL Generation

This feature allows you to generate a basic URL for an image stored in Sanity. You need to provide the project ID and dataset, and then you can generate the URL for a specific image asset.

const imageUrlBuilder = require('@sanity/image-url');
const client = { projectId: 'yourProjectId', dataset: 'yourDataset' };
const builder = imageUrlBuilder(client);
const url = builder.image('image-asset-id').url();
console.log(url);

Image Resizing

This feature allows you to resize an image by specifying the width and height. The generated URL will point to the resized image.

const url = builder.image('image-asset-id').width(300).height(200).url();
console.log(url);

Image Cropping

This feature allows you to crop an image. You can specify different cropping options such as 'center', 'top', 'bottom', etc.

const url = builder.image('image-asset-id').crop('center').url();
console.log(url);

Format Conversion

This feature allows you to convert the image format. For example, you can convert an image to 'webp' format.

const url = builder.image('image-asset-id').format('webp').url();
console.log(url);

Other packages similar to @sanity/image-url

Keywords

FAQs

Package last updated on 31 Oct 2024

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