-
-
Notifications
You must be signed in to change notification settings - Fork 51.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add custom isImgurl prop to Upload Component #23248
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add tests to make sure this change works as expected?
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c4525d6:
|
Codecov Report
@@ Coverage Diff @@
## feature #23248 +/- ##
========================================
Coverage 98.35% 98.35%
========================================
Files 365 365
Lines 7289 7290 +1
Branches 1999 2001 +2
========================================
+ Hits 7169 7170 +1
Misses 120 120
Continue to review full report at Codecov.
|
feature branch |
changed... |
components/upload/index.zh-CN.md
Outdated
@@ -34,6 +34,7 @@ title: Upload | |||
| multiple | 是否支持多选文件,`ie10+` 支持。开启后按住 ctrl 可选择多个文件 | boolean | false | | | |||
| name | 发到后台的文件参数名 | string | 'file' | | | |||
| previewFile | 自定义文件预览逻辑 | (file: File \| Blob) => Promise<dataURL: string> | 无 | | | |||
| isImageUrl | 自定义缩略图是否使用 img 标签进行显示 | (file: UploadFile) => boolean | 无 | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
默认值可以给一个 github 源代码地址。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ok
…---Original---
From: "偏右"<notifications@github.com>
Date: Tue, Apr 14, 2020 18:21 PM
To: "ant-design/ant-design"<ant-design@noreply.github.com>;
Cc: "nick"<745512023@qq.com>;"Author"<author@noreply.github.com>;
Subject: Re: [ant-design/ant-design] feat: add custom isImgurl prop to Upload Component (#23248)
@afc163 commented on this pull request.
In components/upload/index.zh-CN.md:
> @@ -34,6 +34,7 @@ title: Upload | multiple | 是否支持多选文件,`ie10+` 支持。开启后按住 ctrl 可选择多个文件 | boolean | false | | | name | 发到后台的文件参数名 | string | 'file' | | | previewFile | 自定义文件预览逻辑 | (file: File \| Blob) => Promise<dataURL: string> | 无 | | +| isImageUrl | 自定义缩略图是否使用 img 标签进行显示 | (file: UploadFile) => boolean | 无 | |
默认值可以给一个 github 源代码地址。
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
components/upload/index.en-US.md
Outdated
@@ -33,7 +33,7 @@ Uploading is the process of publishing information (web pages, text, pictures, v | |||
| multiple | Whether to support selected multiple file. `IE10+` supported. You can select multiple files with CTRL holding down while multiple is set to be true | boolean | false | | | |||
| name | The name of uploading file | string | 'file' | | | |||
| previewFile | Customize preview file logic | (file: File \| Blob) => Promise<dataURL: string> | - | | | |||
| isImageUrl | Customize if render <img /> in thumbnail | (file: UploadFile) => boolean | - | | | |||
| isImageUrl | Customize if render <img /> in thumbnail | (file: UploadFile) => boolean | [inside implementation](https://github.com/ant-design/ant-design/blob/master/components/upload/utils.tsx) | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ant-design/components/upload/utils.tsx
Lines 47 to 68 in 4ad5830
export const isImageUrl = (file: UploadFile): boolean => { | |
if (file.type) { | |
return isImageFileType(file.type); | |
} | |
const url: string = (file.thumbUrl || file.url) as string; | |
const extension = extname(url); | |
if ( | |
/^data:image\//.test(url) || | |
/(webp|svg|png|gif|jpg|jpeg|jfif|bmp|dpg|ico)$/i.test(extension) | |
) { | |
return true; | |
} | |
if (/^data:/.test(url)) { | |
// other file types of base64 | |
return false; | |
} | |
if (extension) { | |
// other file types which have extension | |
return false; | |
} | |
return true; | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry... i got. done
feat: add custom isImgurl prop to Upload
🤔 这个变动的性质是?
🔗 相关 Issue
#22958
💡 需求背景和解决方案
某些oss服务使用"!"或其他分隔符传递参数,使得文件的thumbUrl不能正确被识别为图片路径。这里增加自定义传入判断是否为图片url的方法,默认仍为内置的判断方法。
📝 更新日志怎么写?
☑️ 请求合并前的自查清单
View rendered components/upload/index.en-US.md
View rendered components/upload/index.zh-CN.md