-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: 이미지 프리뷰 함수 생성 및 분리, 관련 페이지에 적용 (#28)
- 이미지 프리뷰 처리 로직을 별도 함수로 생성 및 분리 - 분리된 프리뷰 함수 재사용으로 코드 중복 제거 - 이미지 업로드 기능이 있는 페이지들에 분리된 함수 적용
- Loading branch information
1 parent
a2e9d87
commit c32d596
Showing
8 changed files
with
27 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export const getImageSrc = (image: File | string): string => { | ||
if (typeof image === 'string') { | ||
// 이미지 URL이 문자열일 경우 그대로 반환 | ||
return image; | ||
} else if (image instanceof File) { | ||
// File 객체일 경우 URL.createObjectURL 사용 | ||
return URL.createObjectURL(image); | ||
} else { | ||
console.error('Invalid image format:', image); | ||
return ''; | ||
} | ||
}; |