[go: up one dir, main page]

Skip to content

Commit

Permalink
🚧 Uppate Post: Use NextImage for better optimization
Browse files Browse the repository at this point in the history
Still needs some work for width/height of rendered images
  • Loading branch information
SABERGLOW committed Oct 18, 2022
1 parent a4db5b0 commit fcaf295
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion components/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react";
import AvatarSubreddit from "./AvatarSubreddit";
import TimeAgo from "react-timeago";
import { LineWobble } from "@uiball/loaders";
import NextImage from "next/image";

import {
ArrowUpIcon,
Expand Down Expand Up @@ -294,9 +295,28 @@ function Post({ post, postId }: Props) {
</div>

{/* Image*/}
{isImage(post?.image) && (
<div className='relative w-full h-96'>
<NextImage
src={post.image}
alt='post image'
layout='fill'
objectFit='cover'
className='rounded-md'
objectPosition='center'
/>
</div>
)}



{/* if post.image is empty or null, don't render it*/}
{/* eslint-disable-next-line @next/next/no-img-element */}
{isImage(post?.image) && (<img className='w-full rounded-md' src={post.image} alt='post'/>)}
{/* {isImage(post?.image) && (<img className='w-full rounded-md' src={post.image} alt='post'/>)} */}
{/* {isImage(post?.image) && (
<NextImage className="w-full rounded-md" objectFit="contain" layout="fill" src={post.image} alt='post' priority/>
)} */}

{/* <img className='w-full rounded-md' src={post.image} alt='post'/> */}

{/* Footer*/}
Expand Down

0 comments on commit fcaf295

Please sign in to comment.