ant-design Upload defaultFileList should allow for fallback image in case of a broken Link.

jslywgbw  于 5个月前  发布在  其他
关注(0)|答案(1)|浏览(89)

What problem does this feature solve?

Problem:

  • I have an Upload component that has a defaultFileList of images.
  • Some of the images have a broken link and the thumbnail being rendered is the default HTML broken image with the alt text. Not very visually pleasing.
  • I'd like to render a fallback image instead.
  • I'm aware I can use renderItem to handle this but then I would be unable to use the default AntD component listing the files. I would have to create my own component.

What does the proposed API look like?

<Upload
    defaultFileList={[
            {
              fallback: "public/images/fallback.svg",
              uid: "0",
              status: "done",
              name: "filename.svg",
              url: "https://***.com/images/filename.svg",
            },
          ]
    }                          
</Upload>

<!-- generated by ant-design-issue-helper. DO NOT REMOVE -->
7bsow1i6

7bsow1i61#

file 里的 fallback 不是 antd 控制的,是上传的文件属性。可以加个 components 来实现

相关问题