Skip to content

fix: update mentor profile image rendering - #273

Open
Deejarh wants to merge 4 commits into
Women-Coding-Community:mainfrom
Deejarh:deejarh-fix-mentor-image
Open

Deejarh wants to merge 4 commits into
Women-Coding-Community:mainfrom
Deejarh:deejarh-fix-mentor-image

Conversation

@Deejarh

@Deejarh Deejarh commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Description

  • Some mentor images fail to render because of Next.js image optimization limits

What Changed

  • Updated the image configuration to allow the required mentor image sources.
  • Verified that mentor images now render correctly where they previously failed.

Type

  • Bug Fix
  • New Feature
  • Code Refactor
  • Documentation
  • Other

Related Issue

Screenshots

BEFORE
Screenshot 2026-04-01 at 15 36 33

AFTER
Screenshot 2026-04-15 at 23 10 50

Testing

Pull request checklist

Please check if your PR fulfills the following requirements:

  • I checked and followed the contributor guide
  • I have tested my changes locally.
  • I have added a screenshot from the website after I tested it locally

@Sowmiya07

Copy link
Copy Markdown
Contributor

@Deejarh Some tests are failing. Can you please fix them?

@sonarqubecloud

Copy link
Copy Markdown

@Deejarh

Deejarh commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

@Deejarh Some tests are failing. Can you please fix them?
@Sowmiya07 done

@womencodingcommunity womencodingcommunity left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for working on the mentor image rendering issue @Deejarh! 🎉

Here are some inline suggestions and feedback.

The main recommendation is to avoid disabling Next.js Image Optimization globally via next.config.mjs (which disables WebP/AVIF generation, compression, and responsive resizing across the entire website) and instead scope unoptimized directly to the <Image unoptimized /> component in MentorProfileCard.tsx alongside a safeguard against infinite fallback error loops.

Comment thread next.config.mjs
return config;
},
images: {
unoptimized: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Setting unoptimized: true globally disables Next.js Image Optimization for all images across the whole website (heroes, event cards, blog posts, etc.).

Instead of disabling optimization globally, we can add the unoptimized prop directly to the specific <Image /> component in MentorProfileCard.tsx.

Suggested change
unoptimized: true,

import { Box, Icon, Tab, Tabs, Typography } from '@mui/material';
import Image from 'next/image';
import React, { useState } from 'react';
import React, { useCallback, useState } from 'react';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
import React, { useCallback, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';

Comment on lines +61 to +66
const [imgSrc, setImgSrc] = useState(
mentor.images[0]?.path || FALLBACK_IMAGE,
);
const handleImageError = useCallback(() => {
setImgSrc(FALLBACK_IMAGE);
}, []);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. Sync imgSrc when the mentor prop updates (e.g. during search/filter re-renders).
  2. Guard against infinite error loops if FALLBACK_IMAGE ever fails to load.
Suggested change
const [imgSrc, setImgSrc] = useState(
mentor.images[0]?.path || FALLBACK_IMAGE,
);
const handleImageError = useCallback(() => {
setImgSrc(FALLBACK_IMAGE);
}, []);
const [imgSrc, setImgSrc] = useState(
mentor.images[0]?.path || FALLBACK_IMAGE,
);
useEffect(() => {
setImgSrc(mentor.images[0]?.path || FALLBACK_IMAGE);
}, [mentor.images]);
const handleImageError = useCallback(() => {
setImgSrc((current) => (current !== FALLBACK_IMAGE ? FALLBACK_IMAGE : current));
}, []);

Comment on lines 110 to +112
width={120}
height={120}
onError={handleImageError}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Adding unoptimized here allows external mentor avatars to bypass Next.js optimization/domain limits without affecting site-wide performance:

Suggested change
width={120}
height={120}
onError={handleImageError}
width={120}
height={120}
unoptimized
onError={handleImageError}

async ({ page }) => {
await expect(page.getByRole('banner')).toHaveScreenshot(
'nav-mobile-closed.png',
{ maxDiffPixels: 100 },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Threshold adjustments for navigation visual regression are unrelated to mentor profile images and should be updated via snapshot update or in a separate navigation PR.

Suggested change
{ maxDiffPixels: 100 },

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants