mirror of
https://github.com/strapi/strapi.git
synced 2025-12-29 08:04:51 +00:00
strapi-plugin-upload: Read responsive breakpoints from config (#9002)
* Read responsive breakpoints from config * Move strapi.config.get into function
This commit is contained in:
parent
175422d760
commit
fd42889083
@ -87,12 +87,14 @@ const optimize = async buffer => {
|
||||
.catch(() => ({ buffer }));
|
||||
};
|
||||
|
||||
const BREAKPOINTS = {
|
||||
const DEFAULT_BREAKPOINTS = {
|
||||
large: 1000,
|
||||
medium: 750,
|
||||
small: 500,
|
||||
};
|
||||
|
||||
const getBreakpoints = () => strapi.config.get('plugins.upload.breakpoints', DEFAULT_BREAKPOINTS);
|
||||
|
||||
const generateResponsiveFormats = async file => {
|
||||
const {
|
||||
responsiveDimensions = false,
|
||||
@ -106,9 +108,10 @@ const generateResponsiveFormats = async file => {
|
||||
|
||||
const originalDimensions = await getDimensions(file.buffer);
|
||||
|
||||
const breakpoints = getBreakpoints();
|
||||
return Promise.all(
|
||||
Object.keys(BREAKPOINTS).map(key => {
|
||||
const breakpoint = BREAKPOINTS[key];
|
||||
Object.keys(breakpoints).map(key => {
|
||||
const breakpoint = breakpoints[key];
|
||||
|
||||
if (breakpointSmallerThan(breakpoint, originalDimensions)) {
|
||||
return generateBreakpoint(key, { file, breakpoint, originalDimensions });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user