Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle blob urls in image component (#27975)
This PR resurrects #23622 which has not been updated in a while. Makes the `Image` component handle `blob:` object urls. closes #23622 fixes #19291 credits: @sdn90 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes
- Loading branch information
1 parent
d14da39
commit daadfd3
Showing
3 changed files
with
47 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import Image from 'next/image' | ||
|
||
const Page = () => { | ||
const [src, setSrc] = useState() | ||
|
||
useEffect(() => { | ||
fetch('/test.jpg') | ||
.then((res) => { | ||
return res.blob() | ||
}) | ||
.then((blob) => { | ||
const url = URL.createObjectURL(blob) | ||
setSrc(url) | ||
}) | ||
}, []) | ||
|
||
return ( | ||
<div> | ||
<p>Blob URL</p> | ||
{src ? <Image id="blob-image" src={src} width="10" height="10" /> : null} | ||
</div> | ||
) | ||
} | ||
|
||
export default Page |
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