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

Update default configuration to match image optimization #17943

Merged
merged 2 commits into from Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 9 additions & 8 deletions packages/next/client/image.tsx
Expand Up @@ -52,7 +52,7 @@ function computeSrc(src: string, host: string, unoptimized: boolean): string {

function callLoader(src: string, host: string, width?: number): string {
let loader = loaders[imageData.hosts[host].loader || 'default']
return loader({ root: imageData.hosts[host].path, filename: src, width })
return loader({ root: imageData.hosts[host].path, src, width })
}

type SrcSetData = {
Expand Down Expand Up @@ -166,18 +166,19 @@ export default function Image({

type LoaderProps = {
root: string
filename: string
src: string
width?: number
}

function imgixLoader({ root, filename, width }: LoaderProps): string {
return `${root}${filename}${width ? '?w=' + width : ''}`
function imgixLoader({ root, src, width }: LoaderProps): string {
return `${root}${src}${width ? '?w=' + width : ''}`
timneutkens marked this conversation as resolved.
Show resolved Hide resolved
}

function cloudinaryLoader({ root, filename, width }: LoaderProps): string {
return `${root}${width ? 'w_' + width + '/' : ''}${filename}`
function cloudinaryLoader({ root, src, width }: LoaderProps): string {
return `${root}${width ? 'w_' + width + '/' : ''}${src}`
}

function defaultLoader({ root, filename }: LoaderProps): string {
return `${root}${filename}`
function defaultLoader({ root, src, width }: LoaderProps): string {
// TODO: change quality parameter to be configurable
return `${root}?url=${src}&width=${width}&q=100`
timneutkens marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion packages/next/next-server/server/config.ts
Expand Up @@ -26,7 +26,7 @@ const defaultConfig: { [key: string]: any } = {
images: {
sizes: [320, 420, 768, 1024, 1200],
domains: [],
hosts: { default: { path: 'defaultconfig' } },
hosts: { default: { path: '/_next/image' } },
},
devIndicators: {
buildActivity: true,
Expand Down