@@ -16,6 +16,7 @@ import {
16
16
} from '@constants'
17
17
import {
18
18
extensionFromMimetype ,
19
+ generateCoverAndThumbnail ,
19
20
getImageDimensions ,
20
21
removeExtension ,
21
22
} from '@utils/mint'
@@ -99,7 +100,6 @@ export const useMintStore = create<MintState>()(
99
100
description,
100
101
tags,
101
102
cover,
102
- thumbnail,
103
103
photosensitive,
104
104
nsfw,
105
105
reset,
@@ -163,7 +163,14 @@ export const useMintStore = create<MintState>()(
163
163
MIMETYPE . ZIP1 ,
164
164
MIMETYPE . ZIP2 ,
165
165
] . includes ( artifact . mimeType )
166
+
166
167
const formats = [ ]
168
+
169
+ const generated = await generateCoverAndThumbnail ( artifact )
170
+
171
+ let used_cover = cover || generated . cover
172
+ let used_thumb = generated . thumbnail
173
+
167
174
if ( artifact . mimeType . indexOf ( 'image' ) === 0 ) {
168
175
const format : Format = {
169
176
mimeType : artifact . mimeType ,
@@ -194,33 +201,35 @@ export const useMintStore = create<MintState>()(
194
201
// TMP: skip GIFs to avoid making static
195
202
if ( artifact . mimeType !== MIMETYPE . GIF ) {
196
203
let coverIsGif = false
197
- if ( cover ) {
198
- coverIsGif = cover . mimeType === MIMETYPE . GIF
204
+ if ( used_cover ) {
205
+ coverIsGif = used_cover . mimeType === MIMETYPE . GIF
199
206
const { imageWidth, imageHeight } = await getImageDimensions (
200
- cover
207
+ used_cover
201
208
)
202
- cover . format = {
203
- mimeType : cover . mimeType ,
204
- fileSize : cover . buffer . byteLength ,
209
+ used_cover . format = {
210
+ mimeType : used_cover . mimeType ,
211
+ fileSize : used_cover . buffer . byteLength ,
205
212
fileName : `${ removeExtension ( artifact . file . name ) } .${
206
- coverIsGif ? 'gif' : extensionFromMimetype ( cover . mimeType )
213
+ coverIsGif
214
+ ? 'gif'
215
+ : extensionFromMimetype ( used_cover . mimeType )
207
216
} `,
208
217
dimensions : {
209
218
value : `${ imageWidth } x${ imageHeight } ` ,
210
219
unit : 'px' ,
211
220
} ,
212
221
}
213
222
}
214
- if ( thumbnail && ! coverIsGif ) {
223
+ if ( used_thumb && ! coverIsGif ) {
215
224
const { imageWidth, imageHeight } = await getImageDimensions (
216
- thumbnail
225
+ used_thumb
217
226
)
218
- thumbnail . format = {
219
- mimeType : thumbnail . mimeType ,
220
- fileSize : thumbnail . buffer . byteLength ,
227
+ used_thumb . format = {
228
+ mimeType : used_thumb . mimeType ,
229
+ fileSize : used_thumb . buffer . byteLength ,
221
230
fileName : `${ removeExtension (
222
231
artifact . file . name
223
- ) } .${ extensionFromMimetype ( thumbnail . mimeType ) } `,
232
+ ) } .${ extensionFromMimetype ( used_thumb . mimeType ) } `,
224
233
dimensions : {
225
234
value : `${ imageWidth } x${ imageHeight } ` ,
226
235
unit : 'px' ,
@@ -241,8 +250,8 @@ export const useMintStore = create<MintState>()(
241
250
tags,
242
251
address : minterAddress ,
243
252
files,
244
- cover,
245
- thumbnail,
253
+ cover : used_cover ,
254
+ thumbnail : used_thumb ,
246
255
generateDisplayUri : true ,
247
256
rights : license ?. value ,
248
257
rightUri : custom_license_uri ,
@@ -259,8 +268,8 @@ export const useMintStore = create<MintState>()(
259
268
tags,
260
269
address : minterAddress ,
261
270
file : artifact ,
262
- cover,
263
- thumbnail,
271
+ cover : used_cover ,
272
+ thumbnail : used_thumb ,
264
273
265
274
rights : license ?. value ,
266
275
rightUri : custom_license_uri ,
0 commit comments