Compressed img & fixed img in postpage

This commit is contained in:
Rykkel
2024-08-10 13:32:44 +08:00
parent 047361615d
commit 196c9d875f
3 changed files with 34 additions and 9 deletions

View File

@@ -261,8 +261,7 @@ export default function CommunityPage() {
<img
src={`${config.serverAddress}/post/post-image/${post.id}`}
className="w-[300px] h-auto rounded-lg object-cover"
onError={() => handleImageError(post.id)}
/>
onError={() => handleImageError(post.id)} />
</div>
)}
</div>

View File

@@ -54,10 +54,18 @@ const PostPage: React.FC = () => {
useEffect(() => {
if (id) {
console.log("useEffect for fetching post called, id:", id);
instance.get(`${config.serverAddress}/post/${id}`)
.then((res) => setPost(res.data))
.then((res) => {
setPost(res.data);
console.log("Post fetch successfully");
})
.catch((error) => console.error("Error fetching post:", error));
}
}, [id]);
useEffect(() => {
console.log("PostPage component mounted");
}, []);
useEffect(() => {
@@ -189,7 +197,8 @@ const PostPage: React.FC = () => {
</div>
{!imageErrorFlags[post.id] && post.postImage && post.postImage !== null && (
<div>
<img src={`${config.serverAddress}/post/post-image/${post.id}`}
<img
src={`${config.serverAddress}/post/post-image/${post.id}`}
alt="PostImage"
className="w-[300px] h-auto rounded-lg object-cover"
onError={() => handleImageError(post.id)} />