Skip to content

Commit 6dd12bc

Browse files
authored
Merge pull request #513 from solid-connection/codex/cdn-upload-unify-main-clean
refactor(web): 이미지 URL 유틸을 normalizeImageUrlToUploadCdn로 단일화
2 parents 874fc51 + b81ec3c commit 6dd12bc

11 files changed

Lines changed: 24 additions & 34 deletions

File tree

apps/web/src/app/(home)/_ui/PopularUniversitySection/_ui/PopularUniversityCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Link from "next/link";
22
import Image from "@/components/ui/FallbackImage";
33
import { getHomeUniversitySlugByName } from "@/constants/university";
44
import type { ListUniversity } from "@/types/university";
5-
import { convertImageUrl } from "@/utils/fileUtils";
5+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
66

77
type PopularUniversityCardProps = {
88
university: ListUniversity;
@@ -32,7 +32,7 @@ const PopularUniversityCard = ({
3232
className="h-[120px] rounded-lg object-cover"
3333
src={
3434
university.backgroundImageUrl
35-
? convertImageUrl(university.backgroundImageUrl)
35+
? normalizeImageUrlToUploadCdn(university.backgroundImageUrl)
3636
: "/svgs/placeholders/university-background-placeholder.svg"
3737
}
3838
width={153}

apps/web/src/app/community/[boardCode]/PostCards.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { IconPostLikeOutline } from "@/public/svgs";
88
import { IconCommunication } from "@/public/svgs/community";
99
import { IconSolidConnentionLogo } from "@/public/svgs/mentor";
1010
import type { ListPost } from "@/types/community";
11+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
1112
import { convertISODateToDate } from "@/utils/datetimeUtils";
12-
import { convertUploadedImageUrl } from "@/utils/fileUtils";
1313

1414
type PostCardsProps = {
1515
posts: ListPost[];
@@ -99,7 +99,7 @@ export const PostCard = ({ post }: { post: ListPost }) => (
9999
{post.postThumbnailUrl ? (
100100
<Image
101101
className="object-cover"
102-
src={convertUploadedImageUrl(post.postThumbnailUrl)}
102+
src={normalizeImageUrlToUploadCdn(post.postThumbnailUrl)}
103103
fill
104104
sizes="80px"
105105
alt="게시글 사진"

apps/web/src/app/community/[boardCode]/[postId]/CommentSection.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import Image from "@/components/ui/FallbackImage";
88
import { DEFAULT_PROFILE_IMAGE } from "@/constants/profile";
99
import { IconMoreVertFilled, IconSubComment } from "@/public/svgs";
1010
import type { Comment as CommentType, CommunityUser } from "@/types/community";
11+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
1112
import { convertISODateToDateTime } from "@/utils/datetimeUtils";
12-
import { convertUploadedImageUrl } from "@/utils/fileUtils";
1313
import CommentInput from "./CommentInput";
1414

1515
type CommentSectionProps = {
@@ -138,7 +138,7 @@ const CommentProfile = ({ user }: { user: CommunityUser }) => {
138138
<div className="h-[25px] w-[25px] rounded-full bg-bg-600">
139139
<Image
140140
className="h-full w-full rounded-full"
141-
src={user?.profileImageUrl ? convertUploadedImageUrl(user?.profileImageUrl) : DEFAULT_PROFILE_IMAGE}
141+
src={user?.profileImageUrl ? normalizeImageUrlToUploadCdn(user?.profileImageUrl) : DEFAULT_PROFILE_IMAGE}
142142
width={40}
143143
height={40}
144144
alt="alt"

apps/web/src/app/community/[boardCode]/[postId]/Content.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { DEFAULT_PROFILE_IMAGE } from "@/constants/profile";
88
import { IconCloseFilled, IconPostLikeFilled, IconPostLikeOutline } from "@/public/svgs";
99
import { IconCommunication } from "@/public/svgs/community";
1010
import type { PostImage as PostImageType, Post as PostType } from "@/types/community";
11+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
1112
import { convertISODateToDateTime } from "@/utils/datetimeUtils";
12-
import { convertUploadedImageUrl } from "@/utils/fileUtils";
1313

1414
export const metadata: Metadata = {
1515
title: "글 상세보기",
@@ -117,7 +117,7 @@ const Content = ({ post, postId }: ContentProps) => {
117117
className="h-full w-full rounded-full object-cover"
118118
src={
119119
post.postFindSiteUserResponse.profileImageUrl
120-
? convertUploadedImageUrl(post.postFindSiteUserResponse.profileImageUrl)
120+
? normalizeImageUrlToUploadCdn(post.postFindSiteUserResponse.profileImageUrl)
121121
: DEFAULT_PROFILE_IMAGE
122122
}
123123
width={40}
@@ -147,7 +147,7 @@ const PostImage = ({ images, onImageClick }: { images: PostImageType[]; onImageC
147147
<div className="mb-3 pr-5">
148148
<div className="relative pt-[75%]">
149149
<Image
150-
src={convertUploadedImageUrl(images[0].url)}
150+
src={normalizeImageUrlToUploadCdn(images[0].url)}
151151
layout="fill"
152152
objectFit="cover"
153153
alt="image"
@@ -163,7 +163,7 @@ const PostImage = ({ images, onImageClick }: { images: PostImageType[]; onImageC
163163
{images.map((image, index) => (
164164
<Image
165165
key={image.id}
166-
src={convertUploadedImageUrl(image.url)}
166+
src={normalizeImageUrlToUploadCdn(image.url)}
167167
width={197}
168168
height={197}
169169
alt="image"
@@ -196,7 +196,7 @@ const ImagePopup = ({ image, title, onClose }: ImagePopupProps) => (
196196
<div />
197197
</div>
198198
<div className="relative flex-grow">
199-
<Image src={convertUploadedImageUrl(image.url)} layout="fill" objectFit="contain" alt="Popup" />
199+
<Image src={normalizeImageUrlToUploadCdn(image.url)} layout="fill" objectFit="contain" alt="Popup" />
200200
</div>
201201
</div>
202202
);

apps/web/src/app/mentor/[id]/_ui/MentorDetialContent/_ui/MentorArticle/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import Image from "@/components/ui/FallbackImage";
44
import { IconLikeFill, IconLikeNotFill } from "@/public/svgs/mentor";
55
import type { Article } from "@/types/news";
6-
import { convertUploadedImageUrl } from "@/utils/fileUtils";
6+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
77
import useLikeToggle from "./_hooks/useLikeToggle";
88

99
interface MentorArticleProps {
@@ -13,7 +13,7 @@ interface MentorArticleProps {
1313

1414
const MentorArticle = ({ article, mentorId }: MentorArticleProps) => {
1515
const { isLiked, handleToggleLike } = useLikeToggle(article.id, mentorId, article.isLiked);
16-
const thumbnailUrl = convertUploadedImageUrl(article.thumbnailUrl);
16+
const thumbnailUrl = normalizeImageUrlToUploadCdn(article.thumbnailUrl);
1717
return (
1818
<div key={article.description} className="overflow-hidden">
1919
{/* 아티클 이미지 */}

apps/web/src/app/mentor/modify/_ui/ModifyContent/_ui/ArticlePanel/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import ReusableDropdown from "@/components/ui/ReusableDropdown";
55
import ArticleThumbPng from "@/public/images/article-thumb.png";
66
import { IconPencil } from "@/public/svgs/mentor";
77
import { type Article, ArticleDropdownType } from "@/types/news";
8+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
89
import { convertISODateToDate } from "@/utils/datetimeUtils";
9-
import { convertUploadedImageUrl } from "@/utils/fileUtils";
1010
import useDeleteDropDownHandler from "./_hooks/useDropDownHandler";
1111

1212
interface ArticlePanelProps {
@@ -25,7 +25,7 @@ const ArticlePanel = ({ article, userId }: ArticlePanelProps) => {
2525
userId,
2626
});
2727

28-
const imageSrc = article.thumbnailUrl ? convertUploadedImageUrl(article.thumbnailUrl) : ArticleThumbPng;
28+
const imageSrc = article.thumbnailUrl ? normalizeImageUrlToUploadCdn(article.thumbnailUrl) : ArticleThumbPng;
2929

3030
return (
3131
<>

apps/web/src/app/my/modify/_ui/ModifyContent/_ui/ImageInputFiled/_hooks/useImageInputHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type ChangeEvent, type RefObject, useEffect, useRef, useState } from "react";
22
import { useController, useFormContext } from "react-hook-form";
33

4-
import { convertUploadedImageUrl } from "@/utils/fileUtils";
4+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
55

66
interface ImageInputHandlerReturn {
77
selectedImage: File | undefined;
@@ -26,7 +26,7 @@ const useImageInputHandler = (initImagePreview: string | null): ImageInputHandle
2626

2727
useEffect(() => {
2828
if (initImagePreview) {
29-
setImagePreviewUrl(convertUploadedImageUrl(initImagePreview));
29+
setImagePreviewUrl(normalizeImageUrlToUploadCdn(initImagePreview));
3030
}
3131
}, [initImagePreview]);
3232

apps/web/src/app/university/[homeUniversity]/[id]/_ui/UniversityDetail/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Image from "@/components/ui/FallbackImage";
22
import LinkifyText from "@/components/ui/LinkifyText";
33
import type { University } from "@/types/university";
4-
import { convertImageUrl } from "@/utils/fileUtils";
4+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
55
import InfoSection from "./_ui/InfoSection";
66
import LanguageSection from "./_ui/LanguageSection";
77
import MapSection from "./_ui/MapSection";
@@ -23,7 +23,7 @@ const UniversityDetail = ({ university, koreanName }: UniversityDetailProps) =>
2323
<div className="relative -z-10 h-60 w-full bg-blue-100">
2424
<Image
2525
alt="대학 이미지"
26-
src={convertImageUrl(university.backgroundImageUrl)}
26+
src={normalizeImageUrlToUploadCdn(university.backgroundImageUrl)}
2727
fill
2828
className="object-cover"
2929
fallbackSrc="/svgs/placeholders/image-placeholder.svg"
@@ -33,7 +33,7 @@ const UniversityDetail = ({ university, koreanName }: UniversityDetailProps) =>
3333
<TitleSection
3434
title={koreanName}
3535
subTitle={university.englishName}
36-
logoUrl={convertImageUrl(university.logoImageUrl)}
36+
logoUrl={normalizeImageUrlToUploadCdn(university.logoImageUrl)}
3737
/>
3838
{/* TODO: totalDispatchCount 추가시 연동, 나라에 국기 추가 */}
3939
<div className="mb-7 mt-10 flex justify-center divide-x">

apps/web/src/components/mentor/ArticleBottomSheetModal/hooks/useArticleSchema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useEffect, useState } from "react";
33
import { useForm } from "react-hook-form";
44
import { useGetMentorMyProfile } from "@/apis/mentor";
55
import { usePostAddArticle, usePutModifyArticle } from "@/apis/news";
6-
import { convertUploadedImageUrl } from "@/utils/fileUtils";
6+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
77
import type { InitialData } from "..";
88
import { type ArticleFormData, articleSchema } from "../lib/schema";
99

@@ -61,7 +61,7 @@ const useArticleSchema = ({
6161
reset(defaultValues); // react-hook-form의 reset 기능으로 defaultValues 설정
6262

6363
// 이미지 미리보기도 초기 데이터로 설정합니다.
64-
const imageSrc = initialData?.thumbnailUrl ? convertUploadedImageUrl(initialData.thumbnailUrl) : null;
64+
const imageSrc = initialData?.thumbnailUrl ? normalizeImageUrlToUploadCdn(initialData.thumbnailUrl) : null;
6565
setImagePreview(imageSrc);
6666
} else {
6767
// 모달이 닫힐 때: 모든 상태를 깨끗하게 초기화합니다.

apps/web/src/components/ui/UniverSityCard/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Image from "@/components/ui/FallbackImage";
33
import CheveronRightFilled from "@/components/ui/icon/ChevronRightFilled";
44
import { getHomeUniversitySlugByName } from "@/constants/university";
55
import type { ListUniversity } from "@/types/university";
6-
import { convertImageUrl } from "@/utils/fileUtils";
6+
import { normalizeImageUrlToUploadCdn } from "@/utils/cdnUrl";
77
import shortenLanguageTestName from "@/utils/universityUtils";
88

99
type UniversityCardProps = {
@@ -31,7 +31,7 @@ const UniversityCard = ({ university, showCapacity = true, linkPrefix = "/univer
3131
<div className="flex flex-shrink-0 items-center">
3232
<Image
3333
className="h-14 w-14 rounded-full object-cover"
34-
src={convertImageUrl(university.logoImageUrl)}
34+
src={normalizeImageUrlToUploadCdn(university.logoImageUrl)}
3535
width={56}
3636
height={56}
3737
alt="대학 이미지"

0 commit comments

Comments
 (0)