Skip to content

Commit 9bb3059

Browse files
committed
[FE] FIX: 크기별 썸네일 적용 변경 #233
1 parent 3e8a50c commit 9bb3059

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/frontend/src/components/VideoCard/index.css.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,24 @@ export const Thumbnail = styled.div<{ $playlistUrl: string | undefined }>`
2626
width: 100%;
2727
height: 100%;
2828
object-fit: cover;
29+
content: url(${props => getYoutubeThumbnail(props.$playlistUrl, 'maxres')});
2930
}
3031
31-
/* 480px 이상: hq 크기 이미지 로드 */
32-
@media (min-width: 480px) {
32+
@media (max-width: 639px) {
3333
& > img {
34-
content: url(${props => getYoutubeThumbnail(props.$playlistUrl, 'hq')});
34+
content: url(${props => getYoutubeThumbnail(props.$playlistUrl, 'sd')});
3535
}
3636
}
3737
38-
/* 640px 이상: sd 크기 이미지 로드 */
39-
@media (min-width: 640px) {
38+
@media (max-width: 479px) {
4039
& > img {
41-
content: url(${props => getYoutubeThumbnail(props.$playlistUrl, 'sd')});
40+
content: url(${props => getYoutubeThumbnail(props.$playlistUrl, 'hq')});
4241
}
4342
}
4443
45-
/* 1280px 이상: maxres 크기 이미지 로드 */
46-
@media (min-width: 1280px) {
44+
@media (max-width: 319px) {
4745
& > img {
48-
content: url(${props => getYoutubeThumbnail(props.$playlistUrl, 'maxres')});
46+
content: url(${props => getYoutubeThumbnail(props.$playlistUrl, 'mq')});
4947
}
5048
}
5149
`;

src/frontend/src/utils/youtubeUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export const getYoutubeVideoInfo = async (videoId: string) => {
77
};
88

99
// 유튜브 썸네일 이미지 가져오기
10-
// maxres: 1280p, sd: 640p, hq: 480p, default: 120p
10+
// maxres: 1280p, sd: 640p, hq: 480p, mq: 320p, default: 120p
1111
export const getYoutubeThumbnail = (
1212
url: string | undefined,
13-
quality: 'default' | 'hq' | 'sd' | 'maxres',
13+
quality: 'default' | 'mq' | 'hq' | 'sd' | 'maxres',
1414
): string | undefined => {
1515
if (!url) return undefined;
1616

@@ -21,6 +21,7 @@ export const getYoutubeThumbnail = (
2121
maxres: 'maxresdefault',
2222
sd: 'sddefault',
2323
hq: 'hqdefault',
24+
mq: 'mqdefault',
2425
default: 'default',
2526
};
2627

0 commit comments

Comments
 (0)