瀏覽代碼

Fixed bug 1478

bugfix/1478
jovan.cirkovic 3 年之前
父節點
當前提交
1f2336c012
共有 1 個檔案被更改,包括 7 行新增2 行删除
  1. 7
    2
      src/components/ImagePicker/ImagePicker.js

+ 7
- 2
src/components/ImagePicker/ImagePicker.js 查看文件

// Check if file is type of string or File // Check if file is type of string or File
useEffect(() => { useEffect(() => {
if (props.image) { if (props.image) {
if (typeof props.image === "string") { if (typeof props.image === "string") {
setImage(getImageUrl(props.image, variants.offerCard)); setImage(getImageUrl(props.image, variants.offerCard));
} else { } else {


// Reads image as both base64 and multipart type // Reads image as both base64 and multipart type
const handleImage = (file) => { const handleImage = (file) => {
if (
file.type !== "image/jpeg" &&
file.type !== "image/jpg" &&
file.type !== "image/png"
)
return;
let reader = new FileReader(); let reader = new FileReader();
reader.readAsDataURL(file); reader.readAsDataURL(file);
reader.onload = () => { reader.onload = () => {
setImage(""); setImage("");
setIsEditing(false); setIsEditing(false);
}; };
return ( return (
<ImagePickerContainer <ImagePickerContainer
className={props.className} className={props.className}

Loading…
取消
儲存