New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/asset-utils

Package Overview
Dependencies
Maintainers
64
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/asset-utils

<!-- This file is AUTO-GENERATED, edit _README.template.md or tweak scripts/generateDocs.ts -->

  • 2.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
192K
increased by2.26%
Maintainers
64
Weekly downloads
 
Created

What is @sanity/asset-utils?

@sanity/asset-utils is a utility library for working with Sanity assets. It provides functions to build URLs for images and files stored in Sanity's content lake, as well as to extract metadata and perform other common tasks related to asset management.

What are @sanity/asset-utils's main functionalities?

Building Image URLs

This feature allows you to build URLs for images stored in Sanity. You need to provide the project ID, dataset, and the source object containing the asset ID.

const { buildImageUrl } = require('@sanity/asset-utils');
const imageUrl = buildImageUrl({ projectId: 'yourProjectId', dataset: 'yourDataset', source: { assetId: 'image-abc123-200x200-png' } });
console.log(imageUrl);

Extracting Metadata

This feature allows you to extract metadata from an asset ID. The metadata includes information such as the asset type, ID, extension, and dimensions.

const { getAsset } = require('@sanity/asset-utils');
const asset = getAsset('image-abc123-200x200-png');
console.log(asset);

Building File URLs

This feature allows you to build URLs for files stored in Sanity. Similar to building image URLs, you need to provide the project ID, dataset, and the source object containing the asset ID.

const { buildFileUrl } = require('@sanity/asset-utils');
const fileUrl = buildFileUrl({ projectId: 'yourProjectId', dataset: 'yourDataset', source: { assetId: 'file-abc123-pdf' } });
console.log(fileUrl);

Other packages similar to @sanity/asset-utils

Keywords

FAQs

Package last updated on 26 Nov 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