-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Having image issues with NextJS images
- Loading branch information
Showing
7 changed files
with
103 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import React from 'react'; | ||
|
||
const ImageComponent = ({ src, ...props }) => { | ||
try { | ||
return React.createElement(require.resolve('next/image').default, { | ||
src: typeof src === 'string' ? src : src.src, | ||
...props, | ||
}); | ||
} catch { | ||
console.log('Not using Next.js'); | ||
return React.createElement('img', { src, ...props }); | ||
} | ||
}; | ||
|
||
export default ImageComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import styles from '../styles/Main.module.css'; | ||
|
||
type projectProps = { | ||
projectId: number; | ||
projectTitle: string; | ||
purpose: string; | ||
techUsed: string; | ||
imageComponent: any; | ||
}; | ||
|
||
export default function Project({ | ||
projectId, | ||
projectTitle, | ||
purpose, | ||
techUsed, | ||
imageComponent, | ||
}: projectProps) { | ||
return ( | ||
<div className={styles.card}> | ||
{imageComponent} | ||
<div className={styles.container}> | ||
<h2> | ||
<b> | ||
Project {projectId}: {projectTitle} | ||
</b> | ||
</h2> | ||
<p> | ||
<strong>Info:</strong> {purpose} | ||
</p> | ||
<p> | ||
<strong>Technologies used:</strong> {techUsed} | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e9ef970
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
portfolio-v3 – ./
portfolio-v3-git-main-ubazdevelops-gmailcom.vercel.app
portfolio-v3-ubazdevelops-gmailcom.vercel.app
portfolio-v3-eight-iota.vercel.app
e9ef970
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
portfolio-v3-21zh – ./
portfolio-v3-21zh-git-main-ubazdevelops-gmailcom.vercel.app
portfolio-v3-21zh-ubazdevelops-gmailcom.vercel.app
portfolio-v3-21zh.vercel.app