Skip to content

Commit

Permalink
fix: thumbnail UI size fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriocomo committed Feb 8, 2025
1 parent 9c2b0a1 commit d585ef7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
36 changes: 14 additions & 22 deletions src/app/components/EditorVideos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface VideoOEmbedItemProps {
}

const WIDTH = 480
const HEIGHT = 480
const HEIGHT = 360

const noThumbnail = `https://placehold.co/${WIDTH}x${HEIGHT}?font=roboto&text=No%20Thumbnail`

Expand Down Expand Up @@ -41,36 +41,28 @@ function VideoOEmbedItem({ url }: VideoOEmbedItemProps) {
loadOEmbed();
}, [loadOEmbed])

//show noThubmbail => isLoading = true
//isLoading = false
//if embed => show embed
//elseif thumbnail => show thumbnail

return (
<Card className='card-img no-after'>
<CardBody>
<CardTitle tag='h5'>
{title}
{title ?? url}
</CardTitle>
{embed ?
<div dangerouslySetInnerHTML={{ __html: embed }}></div>
:
<div className='img-responsive-wrapper'>
<div className='img-responsive'>
<figure className='img-wrapper'>
<img
<CardText>
URL: <a href={url}>{url}</a>
</CardText>
<div className='img-responsive-wrapper'>
<div className='img-responsive'>
<figure className='img-wrapper'>
{embed
? <div dangerouslySetInnerHTML={{ __html: embed }}></div>
: <img
src={thumbnail}
title={title}
alt={title}
/>
</figure>
</div>
/>}
</figure>
</div>
}

<CardText>
URL: <a href={url}>{url}</a>
</CardText>
</div>
</CardBody>
</Card>
)
Expand Down
18 changes: 15 additions & 3 deletions src/app/oembed-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,23 @@ const getOEmbed = async <T extends ProviderResponse>(req: ConsumerRequest): Prom
throw new Error('no matching schema')
}

const response = await fetch(`${matchedUrl}?url=${req.url}`)
const optionalQueryParamsList = [];

const body = await response.json();
if (req.maxheight) {
optionalQueryParamsList.push(['maxheight', req.maxheight]);
}

if (req.maxwidth) {
optionalQueryParamsList.push(['maxwidth', req.maxwidth]);
}

console.log(body)
const optionalQueryParams = optionalQueryParamsList.reduce((p, c) => `${p}&${c[0]}=${c[1]}`, '')

const url = `${matchedUrl}?url=${req.url}&format=json${optionalQueryParams}`; console.log(url)

const response = await fetch(url)

const body = await response.json();

return body
}
Expand Down

0 comments on commit d585ef7

Please sign in to comment.