--- url: "https://web.dev/articles/clipboard/paste-images/pattern" titulek: "web.dev" h1: "" popis: "" jazyk: "en" kanonicka: "https://web.dev/articles/clipboard/paste-images/pattern" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 03:33:05" znaku: 2179 slov: 276 kodovani: "iso-8859-2" sha256: "e1fb05490280ac4832552745d38c2d0b3b127eb2ab223630baafff6e0dfa8b83" --- Stay organized with collections Save and categorize content based on your preferences. HTML `
Hit â + v (for macOS) or ctrl + v (for other operating systems) to paste images anywhere in this page.
` CSS `:root { color-scheme: dark light; } html { box-sizing: border-box; } *, *:before, *:after { box-sizing: inherit; } body { margin: 1rem; font-family: system-ui, sans-serif; } button { display: block; }` JS `document.addEventListener('paste', async (e) => { e.preventDefault(); const clipboardItems = typeof navigator?.clipboard?.read === 'function' ? await navigator.clipboard.read() : e.clipboardData.files; for (const clipboardItem of clipboardItems) { let blob; if (clipboardItem.type?.startsWith('image/')) { // For files from `e.clipboardData.files`. blob = clipboardItem // Do something with the blob. appendImage(blob); } else { // For files from `navigator.clipboard.read()`. const imageTypes = clipboardItem.types?.filter(type => type.startsWith('image/')) for (const imageType of imageTypes) { blob = await clipboardItem.getType(imageType); // Do something with the blob. appendImage(blob); } } } }); const appendImage = (blob) => { const img = document.createElement('img'); img.src = URL.createObjectURL(blob); document.body.append(img); };` Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2026-07-29 UTC.