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

Image Component: Support for Akamai image CDN #18100

Merged
merged 1 commit into from Oct 21, 2020
Merged
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
5 changes: 5 additions & 0 deletions packages/next/client/image.tsx
Expand Up @@ -4,6 +4,7 @@ import Head from '../next-server/lib/head'
const loaders: { [key: string]: (props: LoaderProps) => string } = {
imgix: imgixLoader,
cloudinary: cloudinaryLoader,
akamai: akamaiLoader,
default: defaultLoader,
}

Expand Down Expand Up @@ -308,6 +309,10 @@ function imgixLoader({ root, src, width, quality }: LoaderProps): string {
return `${root}${normalizeSrc(src)}${paramsString}`
}

function akamaiLoader({ root, src, width }: LoaderProps): string {
return `${root}${normalizeSrc(src)}${width ? '?imwidth=' + width : ''}`
Copy link
Member

@styfle styfle Oct 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Akamai support an auto-format feature like imgix or cloudinary?

Also, what about the q quality param?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, as far as I can tell Akamai only supports width as a URL parameter (https://developer.akamai.com/api/web_performance/image_manager/v2.html). Quality is something the app developers will have to set using their own Akamai image policies.

I mentioned that in the description for this PR, but maybe I should add it as a comment in the code as well

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. I misunderstood "your side". Sounds like that means the "Akamai Dashboard" or something where its the same quality across all images?

}

function cloudinaryLoader({ root, src, width, quality }: LoaderProps): string {
const params = []
let paramsString = ''
Expand Down