netlify-image-cdn
Transform, resize, crop, reformat, and optimize images on demand via Netlify Image CDN's /.netlify/images endpoint. Use when adding responsive images, generating thumbnails, converting formats (avif/webp/png), cropping to aspect ratios, tuning image quality, creating blurred placeholders, allowlisting remote image domains, serving user-uploaded images, or wiring framework image components (Next.js, Astro, Nuxt, Angular, Gatsby) to Netlify. Triggers on tasks like "optimize images", "add image thu
Security Assessment
About netlify-image-cdn
This skill explains how to transform, resize, crop, reformat, and optimize images on demand using Netlify Image CDN's built-in /.netlify/images edge endpoint, which requires no function or file authoring. It solves the everyday need for responsive images, thumbnails, format conversion, and optimization without a custom image pipeline. The endpoint is driven purely by query parameters, and the skill documents each one (url, w, h, fit, position, fm, q), the exact behavior of contain/cover/fill fitting, content negotiation to AVIF/WebP based on the browser Accept header, and response codes.
Beyond the core endpoint, it covers allowlisting remote source domains in netlify.toml (with precise guidance on regex escaping and percent-encoding remote URLs), reusable transformation presets via redirects, cache-control headers, framework image components, and the special case that fm=blurhash returns a text string to decode client-side rather than image bytes. A companion reference walks through a complete user-uploaded image pipeline that composes Netlify Functions, Netlify Blobs, and the Image CDN — an upload handler that validates MIME type and size server-side, a serve handler, and CDN redirect presets — with React and Astro examples.
Target users are web and full-stack developers building responsive image delivery, thumbnail systems, or user-upload galleries on Netlify. The guidance is benign and even security-aware: it stresses that file type and size must be validated on the server because client validation can be bypassed, and that Netlify does not forward Authorization or Cookie headers to remote sources.
FAQ
How do I transform an image?
Request /.netlify/images with query parameters, for example ?url=/owl.jpeg&fit=cover&w=50&h=50&fm=webp&q=80. Only url is required; it is a built-in edge endpoint needing no function or file authoring.
How do I serve images from an external domain?
Allowlist the domain with a remote_images pattern in netlify.toml, escaping only the dot in the hostname, then percent-encode the remote URL with encodeURIComponent before placing it in the url param. Remote sources must be publicly accessible.
Why does fm=blurhash render nothing?
fm=blurhash returns a BlurHash text string, not image bytes. Fetch it ahead of time, decode it client-side with a BlurHash library, then load the real image as a separate request without fm=blurhash.
What does fit=cover require?
fit=cover requires both w and h; supplying only one silently misbehaves. cover keeps exact dimensions by cropping, contain preserves aspect ratio without cropping, and fill stretches to exact dimensions.
How should I handle user-uploaded images securely?
The reference pipeline validates file MIME type and size on the server (since client validation can be bypassed), stores the binary in Netlify Blobs, serves it through a function, and layers Image CDN transformations via redirect presets.
Install netlify-image-cdn
Quick Setup:
- Copy the skill folder to
.claude/skills/ - Claude will automatically detect and use the skill
Repository
netlify/context-and-tools