mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
fix(vercel): Fix srcset generation not working on Vercel (#10756)
* fix(vercel): Fix `srcset` generation not working on Vercel * chore: changeset * fix: remove densities and widths from the HTML attributes * nit: better changeset * nit: add formats
This commit is contained in:
parent
17c2bb1aad
commit
c75ededdb4
3 changed files with 12 additions and 1 deletions
7
.changeset/nine-radios-peel.md
Normal file
7
.changeset/nine-radios-peel.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
"@astrojs/vercel": patch
|
||||
---
|
||||
|
||||
Fixes `widths` and `densities` not working when using Vercel's Image Optimization.
|
||||
|
||||
Note that you still need to make sure that the widths you're outputting are enabled in [the `imageConfig` property of the Vercel adapter](https://docs.astro.build/en/guides/integrations-guide/vercel/#imagesconfig) in order for these properties to work.
|
|
@ -1,7 +1,9 @@
|
|||
import type { ExternalImageService } from 'astro';
|
||||
import { isESMImportedImage, sharedValidateOptions } from './shared.js';
|
||||
import { baseService } from 'astro/assets';
|
||||
|
||||
const service: ExternalImageService = {
|
||||
...baseService,
|
||||
validateOptions: (options, serviceOptions) =>
|
||||
sharedValidateOptions(options, serviceOptions.service.config, 'production'),
|
||||
getHTMLAttributes(options) {
|
||||
|
@ -29,7 +31,7 @@ const service: ExternalImageService = {
|
|||
}
|
||||
}
|
||||
|
||||
const { src, width, height, format, quality, ...attributes } = props;
|
||||
const { src, width, height, format, quality, densities, widths, formats, ...attributes } = options;
|
||||
|
||||
return {
|
||||
...attributes,
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import type { LocalImageService } from 'astro';
|
||||
import { baseService } from 'astro/assets';
|
||||
import { sharedValidateOptions } from './shared.js';
|
||||
|
||||
export const baseDevService: Omit<LocalImageService, 'transform'> = {
|
||||
...baseService,
|
||||
validateOptions: (options, serviceOptions) =>
|
||||
sharedValidateOptions(options, serviceOptions.service.config, 'development'),
|
||||
getURL(options) {
|
||||
|
|
Loading…
Reference in a new issue