37f9d56d49
* Accept audio & video files for upload * Rename image related variables * Implement getAssetType util * Preview & upload support for video files * Preview & upload support for audio files * Preview update for audio files * New look for audio previews on asset list * Remove extra refs Co-authored-by: findolor <anakisci@gmail.com>
12 lines
537 B
TypeScript
12 lines
537 B
TypeScript
/* eslint-disable eslint-comments/disable-enable-pair */
|
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
export type AssetType = 'image' | 'audio' | 'video' | 'unknown'
|
|
|
|
export const getAssetType = (assetFileName: string): AssetType => {
|
|
const assetType = assetFileName?.split('.').pop() || 'unknown'
|
|
if (assetType === 'png' || assetType === 'jpg' || assetType === 'jpeg') return 'image'
|
|
if (assetType === 'mp3' || assetType === 'wav') return 'audio'
|
|
if (assetType === 'mp4') return 'video'
|
|
return 'unknown'
|
|
}
|