File tree Expand file tree Collapse file tree 6 files changed +19
-11
lines changed
elements/Table/DefaultCell/fields/File Expand file tree Collapse file tree 6 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -55,10 +55,9 @@ export { formatFolderOrDocumentItem } from '../folders/utils/formatFolderOrDocum
5555export { validOperators , validOperatorSet } from '../types/constants.js'
5656
5757export { formatFilesize } from '../uploads/formatFilesize.js'
58-
5958export { isImage } from '../uploads/isImage.js'
60- export { combineWhereConstraints } from '../utilities/combineWhereConstraints.js'
6159
60+ export { combineWhereConstraints } from '../utilities/combineWhereConstraints.js'
6261export {
6362 deepCopyObject ,
6463 deepCopyObjectComplex ,
@@ -74,12 +73,14 @@ export {
7473} from '../utilities/deepMerge.js'
7574
7675export { extractID } from '../utilities/extractID.js'
76+
7777export { fieldSchemaToJSON } from '../utilities/fieldSchemaToJSON.js'
7878export { flattenAllFields } from '../utilities/flattenAllFields.js'
79-
8079export { default as flattenTopLevelFields } from '../utilities/flattenTopLevelFields.js'
80+
8181export { formatAdminURL } from '../utilities/formatAdminURL.js'
8282export { formatLabels , toWords } from '../utilities/formatLabels.js'
83+ export { getBestFitFromSizes } from '../utilities/getBestFitFromSizes.js'
8384export { getDataByPath } from '../utilities/getDataByPath.js'
8485
8586export { getFieldPermissions } from '../utilities/getFieldPermissions.js'
Original file line number Diff line number Diff line change 11import type { CollectionSlug , Document } from '../../index.js'
22import type { FolderOrDocument } from '../types.js'
33
4+ import { isImage } from '../../uploads/isImage.js'
5+ import { getBestFitFromSizes } from '../../utilities/getBestFitFromSizes.js'
6+
47type Args = {
58 folderFieldName : string
69 isUpload : boolean
@@ -26,7 +29,15 @@ export function formatFolderOrDocumentItem({
2629 if ( isUpload ) {
2730 itemValue . filename = value . filename
2831 itemValue . mimeType = value . mimeType
29- itemValue . url = value . url
32+ itemValue . url = isImage ( value . mimeType )
33+ ? getBestFitFromSizes ( {
34+ sizes : value . sizes ,
35+ targetSizeMax : 520 ,
36+ targetSizeMin : 300 ,
37+ url : value . url ,
38+ width : value . width ,
39+ } )
40+ : undefined
3041 }
3142
3243 return {
File renamed without changes.
Original file line number Diff line number Diff line change @@ -6,11 +6,10 @@ import type {
66 UploadFieldClient ,
77} from 'payload'
88
9- import { isImage } from 'payload/shared'
9+ import { getBestFitFromSizes , isImage } from 'payload/shared'
1010import React from 'react'
1111
1212import './index.scss'
13- import { getBestFitFromSizes } from '../../../../../utilities/getBestFitFromSizes.js'
1413import { Thumbnail } from '../../../../Thumbnail/index.js'
1514
1615const baseClass = 'file'
Original file line number Diff line number Diff line change @@ -11,14 +11,12 @@ import { UploadCard } from '../UploadCard/index.js'
1111
1212const baseClass = 'upload upload--has-many'
1313
14- import { isImage } from 'payload/shared'
14+ import { getBestFitFromSizes , isImage } from 'payload/shared'
1515
1616import './index.scss'
1717
1818import type { ReloadDoc } from '../types.js'
1919
20- import { getBestFitFromSizes } from '../../../utilities/getBestFitFromSizes.js'
21-
2220type Props = {
2321 readonly className ?: string
2422 readonly displayPreview ?: boolean
Original file line number Diff line number Diff line change 22
33import type { JsonObject } from 'payload'
44
5- import { isImage } from 'payload/shared'
5+ import { getBestFitFromSizes , isImage } from 'payload/shared'
66import React from 'react'
77
88import type { ReloadDoc } from '../types.js'
99
10- import { getBestFitFromSizes } from '../../../utilities/getBestFitFromSizes.js'
1110import './index.scss'
1211import { RelationshipContent } from '../RelationshipContent/index.js'
1312import { UploadCard } from '../UploadCard/index.js'
You can’t perform that action at this time.
0 commit comments