-
Notifications
You must be signed in to change notification settings - Fork 5
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
Allow gif and svg to be uploaded #18
base: develop
Are you sure you want to change the base?
Allow gif and svg to be uploaded #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @evoactivity. Thank you for the PR. Please take a look at the comments below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are now maintaining two set of formats: generally-allowed formats and processable formats, you need to improve the tests to show that the non-processable formats are merely uploaded without formatting.
] | ||
|
||
// Formats we want to be safely processed by sharp | ||
export const conversionFormats: Array<AllowedFormats> = ['jpeg', 'png', 'webp', 'avif', 'tiff'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename variable to processableFormats
. Also append as const
to the array.
You should also exclude the non-processable formats from the assigned type: Array<AllowedFormat>
. E.g. Array<Exclude<AllowedFormat, 'gif' | 'svg' | 'svg+xml'>>
@@ -67,17 +67,26 @@ export const resizeTo = async function ( | |||
export const breakpointSmallerThan = (breakpoint: number, { width, height }: FileDimensions) => | |||
breakpoint < width! || breakpoint < height! | |||
|
|||
export const allowedFormats: Array<AttachmentOptions['forceFormat']> = [ | |||
export type AllowedFormats = 'jpeg' | 'png' | 'webp' | 'avif' | 'tiff' | 'gif' | 'svg' | 'svg+xml' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename union type to single: AllowedFormat
Allows gif and svg to be uploaded without being converted by sharp for breakpoints and thumbnails.
I'm running this on several projects with no problems.