Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Created a FallbackImage component to handle broken images #1758

Merged
merged 3 commits into from
Oct 19, 2022

Conversation

Yazdun
Copy link
Contributor

@Yazdun Yazdun commented Sep 15, 2022

Changes proposed

I noticed that some of the profile images are broken, so the alt text is being used instead of an image which doesn't look very nice. I created a simple custom FallbackImage component which uses the NextJS Image component and all it's powers, but it handles broken images more gracefully and it shows a dynamic SVG image based on a given prop.

I used DiceBear Avatars to generate dynamic SVGs for the broken images.

Two files had broken profile image issue, [username].js and UserPreview.js . I edited both of these files and switched the default NextJS Image component with the FallbackImage component.

Check List (Check all the applicable boxes)

  • My code follows the code style of this project.
  • My change requires changes to the documentation.
  • I have updated the documentation accordingly.
  • All new and existing tests passed.
  • This PR does not contain plagiarized content.
  • The title of my pull request is a short description of the requested changes.

Screenshots

before changes :

before changes

after changes :

after changes

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's great having you contribute to this project

Welcome to the community 🤓

If you would like to continue contributing to open source and would like to do it with an awesome inclusive community, you should join our Discord chat and our GitHub Organisation - we help and encourage each other to contribute to open source little and often 🤓 . Any questions let us know.

@Panquesito7 Panquesito7 added ✨ goal: improvement undefined 🟨 priority: medium undefined medium Pull request with changed lines between 10 and 30 labels Sep 15, 2022
Copy link
Member

@eddiejaoude eddiejaoude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great 👍 Thank you

@github-actions github-actions bot added the v2 label Oct 19, 2022
import { useState } from "react";
import Image from "next/image";

export const FallbackImage = ({ src, alt, fallback = "A A", ...rest }) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a default export will be better here, but it is not a blocker to get this merged in

@eddiejaoude eddiejaoude merged commit 2ae3ec8 into EddieHubCommunity:nextjs Oct 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✨ goal: improvement undefined medium Pull request with changed lines between 10 and 30 🟨 priority: medium undefined
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants