@evfrenkel/decap-cms-core 3.13.0-image-conversions.0 → 3.13.0-image-conversions.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@evfrenkel/decap-cms-core.js +1 -1
- package/dist/@evfrenkel/decap-cms-core.js.map +1 -1
- package/dist/esm/bootstrap.js +2 -2
- package/dist/esm/components/UI/ErrorBoundary.js +2 -2
- package/dist/esm/lib/imageTransformations.js +4 -1
- package/package.json +1 -1
- package/src/lib/__tests__/imageTransformations.spec.ts +11 -0
- package/src/lib/imageTransformations.ts +20 -2
package/dist/esm/bootstrap.js
CHANGED
|
@@ -49,8 +49,8 @@ function bootstrap(opts = {}) {
|
|
|
49
49
|
/**
|
|
50
50
|
* Log the version number.
|
|
51
51
|
*/
|
|
52
|
-
if (typeof "3.13.0-image-conversions.
|
|
53
|
-
console.log(`decap-cms-core ${"3.13.0-image-conversions.
|
|
52
|
+
if (typeof "3.13.0-image-conversions.1" === 'string') {
|
|
53
|
+
console.log(`decap-cms-core ${"3.13.0-image-conversions.1"}`);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
@@ -42,8 +42,8 @@ function buildIssueTemplate({
|
|
|
42
42
|
let version = '';
|
|
43
43
|
if (typeof DECAP_CMS_VERSION === 'string') {
|
|
44
44
|
version = `decap-cms@${DECAP_CMS_VERSION}`;
|
|
45
|
-
} else if (typeof "3.12.2-image-conversions.
|
|
46
|
-
version = `decap-cms-app@${"3.12.2-image-conversions.
|
|
45
|
+
} else if (typeof "3.12.2-image-conversions.1" === 'string') {
|
|
46
|
+
version = `decap-cms-app@${"3.12.2-image-conversions.1"}`;
|
|
47
47
|
}
|
|
48
48
|
const template = getIssueTemplate({
|
|
49
49
|
version,
|
|
@@ -2,8 +2,11 @@ import { join } from 'path';
|
|
|
2
2
|
import { basename, fileExtension, fileExtensionWithSeparator } from 'decap-cms-lib-util';
|
|
3
3
|
const TRANSFORMATIONS_FOLDER = '_transformations';
|
|
4
4
|
const SUPPORTED_OUTPUT_FORMATS = ['jpg', 'jpeg', 'png', 'webp'];
|
|
5
|
+
function hasImageTransformationsGetter(field) {
|
|
6
|
+
return typeof field?.get === 'function';
|
|
7
|
+
}
|
|
5
8
|
function getFieldImageTransformations(field) {
|
|
6
|
-
const imageTransformations = field
|
|
9
|
+
const imageTransformations = hasImageTransformationsGetter(field) ? field.get('image_transformations') : field?.image_transformations;
|
|
7
10
|
return imageTransformations?.toJS ? imageTransformations.toJS() : imageTransformations;
|
|
8
11
|
}
|
|
9
12
|
function normalizeVariant(variant) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evfrenkel/decap-cms-core",
|
|
3
3
|
"description": "Decap CMS core application, see decap-cms package for the main distribution.",
|
|
4
|
-
"version": "3.13.0-image-conversions.
|
|
4
|
+
"version": "3.13.0-image-conversions.1",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"main": "dist/decap-cms-core.js",
|
|
7
7
|
"files": [
|
|
@@ -50,6 +50,17 @@ describe('imageTransformations', () => {
|
|
|
50
50
|
variants: [{ name: 'field', width: 200 }],
|
|
51
51
|
});
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
it('supports plain object field config from media upload options', () => {
|
|
55
|
+
const field = {
|
|
56
|
+
image_transformations: [{ name: 'field', width: 200 }],
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
expect(getImageTransformationsConfig({}, field)).toEqual({
|
|
60
|
+
keepOriginal: true,
|
|
61
|
+
variants: [{ name: 'field', width: 200 }],
|
|
62
|
+
});
|
|
63
|
+
});
|
|
53
64
|
});
|
|
54
65
|
|
|
55
66
|
describe('shouldTransformImage', () => {
|
|
@@ -28,11 +28,29 @@ export type ImageTransformationFile = {
|
|
|
28
28
|
original?: boolean;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
type PlainFieldImageTransformations = {
|
|
32
|
+
image_transformations?: CmsImageTransformations;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
type FieldImageTransformationsGetter = {
|
|
36
|
+
get: (key: 'image_transformations') => CmsImageTransformations | undefined;
|
|
37
|
+
};
|
|
38
|
+
|
|
31
39
|
const TRANSFORMATIONS_FOLDER = '_transformations';
|
|
32
40
|
const SUPPORTED_OUTPUT_FORMATS = ['jpg', 'jpeg', 'png', 'webp'];
|
|
33
41
|
|
|
34
|
-
function
|
|
35
|
-
|
|
42
|
+
function hasImageTransformationsGetter(
|
|
43
|
+
field: EntryField | PlainFieldImageTransformations | undefined,
|
|
44
|
+
): field is EntryField & FieldImageTransformationsGetter {
|
|
45
|
+
return typeof (field as FieldImageTransformationsGetter | undefined)?.get === 'function';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getFieldImageTransformations(field?: EntryField | PlainFieldImageTransformations) {
|
|
49
|
+
const imageTransformations = (
|
|
50
|
+
hasImageTransformationsGetter(field)
|
|
51
|
+
? field.get('image_transformations')
|
|
52
|
+
: (field as PlainFieldImageTransformations | undefined)?.image_transformations
|
|
53
|
+
) as
|
|
36
54
|
| (CmsImageTransformations & { toJS?: () => CmsImageTransformations })
|
|
37
55
|
| undefined;
|
|
38
56
|
|