mirror of
https://github.com/strapi/strapi.git
synced 2025-08-22 15:48:59 +00:00
chore: remove deprecated isSupportedImage
This commit is contained in:
parent
b9aef55175
commit
01dfca22b2
@ -36,7 +36,7 @@ module.exports = ({ strapi }) => {
|
|||||||
const fileTypeName = getTypeName(fileModel);
|
const fileTypeName = getTypeName(fileModel);
|
||||||
const fileEntityResponseType = getEntityResponseName(fileModel);
|
const fileEntityResponseType = getEntityResponseName(fileModel);
|
||||||
|
|
||||||
const { optimize, isSupportedImage } = getUploadService('image-manipulation');
|
const { optimize, isOptimizableImage } = getUploadService('image-manipulation');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimize and format a file using the upload services
|
* Optimize and format a file using the upload services
|
||||||
@ -64,7 +64,7 @@ module.exports = ({ strapi }) => {
|
|||||||
);
|
);
|
||||||
currentFile.getStream = createReadStream;
|
currentFile.getStream = createReadStream;
|
||||||
|
|
||||||
if (!(await isSupportedImage(currentFile))) {
|
if (!(await isOptimizableImage(currentFile))) {
|
||||||
return currentFile;
|
return currentFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,15 +174,6 @@ const breakpointSmallerThan = (breakpoint, { width, height }) => {
|
|||||||
return breakpoint < width || breakpoint < height;
|
return breakpoint < width || breakpoint < height;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO V5: remove isSupportedImage
|
|
||||||
const isSupportedImage = (...args) => {
|
|
||||||
process.emitWarning(
|
|
||||||
'[deprecated] In future versions, `isSupportedImage` will be removed. Replace it with `isImage` or `isOptimizableImage` instead.'
|
|
||||||
);
|
|
||||||
|
|
||||||
return isOptimizableImage(...args);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies a simple image transformation to see if the image is faulty/corrupted.
|
* Applies a simple image transformation to see if the image is faulty/corrupted.
|
||||||
*/
|
*/
|
||||||
@ -234,7 +225,6 @@ const isImage = async (file) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports = () => ({
|
module.exports = () => ({
|
||||||
isSupportedImage,
|
|
||||||
isFaultyImage,
|
isFaultyImage,
|
||||||
isOptimizableImage,
|
isOptimizableImage,
|
||||||
isResizableImage,
|
isResizableImage,
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
import type { Transform } from 'jscodeshift';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces calls to isSupportedImage with isOptimizableImage
|
||||||
|
*/
|
||||||
|
|
||||||
|
const transform: Transform = (file, api) => {
|
||||||
|
// Extract the jscodeshift API
|
||||||
|
const { j } = api;
|
||||||
|
// Parse the file content
|
||||||
|
const root = j(file.source);
|
||||||
|
|
||||||
|
// Find and update the destructuring assignment
|
||||||
|
root
|
||||||
|
.find(j.VariableDeclarator, {
|
||||||
|
init: {
|
||||||
|
callee: {
|
||||||
|
object: { callee: { property: { name: 'getUploadService' } } },
|
||||||
|
arguments: [{ value: 'image-manipulation' }],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.forEach((path) => {
|
||||||
|
if (path.node.id.type === 'ObjectPattern') {
|
||||||
|
path.node.id.properties.forEach((property) => {
|
||||||
|
if (property.key.type === 'Identifier' && property.key.name === 'isSupportedImage') {
|
||||||
|
property.key.name = 'isOptimizableImage';
|
||||||
|
if (property.value && property.value.type === 'Identifier') {
|
||||||
|
property.value.name = 'isOptimizableImage';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update calls to isSupportedImage
|
||||||
|
root.find(j.Identifier, { name: 'isSupportedImage' }).forEach((path) => {
|
||||||
|
path.node.name = 'isOptimizableImage';
|
||||||
|
});
|
||||||
|
|
||||||
|
// Return the updated file content
|
||||||
|
return root.toSource();
|
||||||
|
};
|
||||||
|
|
||||||
|
export default transform;
|
Loading…
x
Reference in New Issue
Block a user