Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

base64 encoded image not dispaying in material ui CardMedia

hi im trying to implement material ui card component

 <CardMedia
                        className={classes.media}
                        title="Contemplative Reptile"
                     src={'data:image/jpeg;base64,/9j/4AAQSkZJRgAtXpVp8YbaRdxnam/SvPJ/>

im trying to display the image in base64 encoded string format but image is not rendering

like image 757
javaworld Avatar asked Oct 13 '25 09:10

javaworld


1 Answers

I just came across this problem myself and resolved it by setting the component prop on the CardMedia component to img and by using the src prop instead of the img prop:

<CardMedia component='img' src={`data:image/png;base64, ${encodedImg}`} />
like image 125
Joshua Maffuccio Avatar answered Oct 16 '25 05:10

Joshua Maffuccio



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!