Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vercel: Removed restriction to use only predefined width's #1181

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/runtime/providers/vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { ProviderGetImage } from '../../types'
// https://vercel.com/docs/more/adding-your-framework#images

export const getImage: ProviderGetImage = (src, { modifiers, baseURL = '/_vercel/image' } = {}, ctx) => {
const validWidths = Object.values(ctx.options.screens || {}).sort((a, b) => a - b)
const largestWidth = validWidths[validWidths.length - 1]
let width = Number(modifiers?.width || 0)

Expand All @@ -14,12 +13,6 @@ export const getImage: ProviderGetImage = (src, { modifiers, baseURL = '/_vercel
// eslint-disable-next-line
console.warn(`A defined width should be provided to use the \`vercel\` provider. Defaulting to \`${largestWidth}\`. Warning originated from \`${src}\`.`)
}
} else if (!validWidths.includes(width)) {
width = validWidths.find(validWidth => validWidth > width) || largestWidth
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line
console.warn(`The width being used (\`${modifiers?.width}\`) should be added to \`image.screens\`. Defaulting to \`${width}\`. Warning originated from \`${src}\`.`)
}
}

if (process.env.NODE_ENV === 'development') {
Expand Down