Appearance
isImageFilePath 判断图片文件路径
function isImageFilePath(filePath: string): boolean
判断文件路径是否为图片文件,依据后缀是否属于 ImageFileSuffixEnum。
参数
| 参数名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| filePath | 待判断的文件路径 | string | 必填 |
返回值
| 返回值 | 说明 | 类型 |
|---|---|---|
| result | 是图片文件路径时返回 true,否则返回 false | boolean |
示例
typescript
import { isImageFilePath } from '@mingto/tools'
isImageFilePath('/assets/photo.jpg') // true
isImageFilePath('/assets/photo.webp?size=small') // true
isImageFilePath('/assets/video.mp4') // false