Skip to content

isImageFilePath 判断图片文件路径

function isImageFilePath(filePath: string): boolean

判断文件路径是否为图片文件,依据后缀是否属于 ImageFileSuffixEnum

参数

参数名说明类型默认值
filePath待判断的文件路径string必填

返回值

返回值说明类型
result是图片文件路径时返回 true,否则返回 falseboolean

示例

typescript
import { isImageFilePath } from '@mingto/tools'

isImageFilePath('/assets/photo.jpg') // true
isImageFilePath('/assets/photo.webp?size=small') // true
isImageFilePath('/assets/video.mp4') // false