Files
zcli-playground/cdn/index-local.html
T
2026-02-08 10:25:39 +01:00

32 lines
1011 B
HTML

<!DOCTYPE html>
<html>
<head>
<title>Fetch Image Example</title>
</head>
<body>
<h1>Image loaded with fetch</h1>
<div id="image-container"></div>
<img height="128" src="https://app.zerops.matejpavlicek.cz/static/gopher-profilovka.png" alt="gopher"/>
<img height="128" src="https://nginx-fd5.prg1.zerops.app/static/gopher-profilovka.png" alt="gopher-with-cors"/>
<script>
fetch('https://cz-url.cdn.zerops.app/nginx.zerops.matejpavlicek.cz/static/gopher-profilovka-2.png')
.then(response => response.blob())
.then(blob => {
const objectURL = URL.createObjectURL(blob);
const img = document.createElement('img');
img.height = 128;
img.src = objectURL;
document.getElementById('image-container').appendChild(img);
img.onload = () => {
URL.revokeObjectURL(objectURL);
};
})
.catch(error => {
console.error('Error:', error);
});
</script>
</body>
</html>