Skip to content

Astro with Netlify adapter: respect value of imageCDN option #864

Description

@krisbalintona

Describe the bug
In an Astro project, one can use the Netlify Astro adapter with the imageCDN option set to false. This means images will not use Netlify's image CDN.

When using Unpic, Unpic will auto-detect the value of fallbackService if it is omitted from the user config. However, when netlify({ imageCDN: false }) is set, fallbackService is "netlify" instead of "sharp", causing broken images.

To Reproduce
Use the following Astro config on a site with image content:

// @ts-check

import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify";
import { imageService } from "@unpic/astro/service";

// https://astro.build/config
export default defineConfig({
  image: { service: imageService() },
  adapter: netlify({ imageCDN: false }),
});

Notice that generated images have paths under /.netlify/..., which assumes that the Netlify image CDN is being used, when it isn't.

Expected behavior
The default fallbackService should be auto-detected as "sharp" instead of "netlify".

Screenshots
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions