Skip to content

Commit 8031981

Browse files
committed
feat: 캡쳐 이미지 다운로드 기능 추가
1 parent dfb30a7 commit 8031981

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

frontend/views/examples/capture/index.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<hr />
1717

1818
<div id="output">
19-
<strong>Capture images</strong>
19+
<strong>Capture images (아래 캡쳐된 이미지를 클릭하면 다운로드 할 수 있습니다)</strong>
2020
<div id="images"></div>
2121
</div>
2222

frontend/views/examples/capture/js/main.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ function capture() {
1919
function insertImage(imageData) {
2020
const $images = document.querySelector('#images');
2121
const $img = document.createElement('img');
22+
const $a = document.createElement('a');
23+
const fileName = `[WebRTC 연구실] Capture - ${new Date().getTime()}`;
2224

2325
$img.src = imageData;
24-
$images.insertBefore($img, $images.childNodes[0]);
26+
$a.href = imageData;
27+
$a.download = fileName;
28+
$a.appendChild($img);
29+
30+
$images.insertBefore($a, $images.childNodes[0]);
2531
}
2632

2733
/**

0 commit comments

Comments
 (0)