# Paste image from clipboard to a variable

**URL:** <https://community.weweb.io/t/paste-image-from-clipboard-to-a-variable/14904>\
**Category:** How do I?\
**Created:** [December 11, 2024, 7:06am UTC](https://community.weweb.io/t/paste-image-from-clipboard-to-a-variable/14904 "2024-12-11T07:06:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dingan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dingan/32/10624_2.png) [@dingan](https://community.weweb.io/u/dingan)\
**Post date:** [December 11, 2024, 7:06am UTC](https://community.weweb.io/t/paste-image-from-clipboard-to-a-variable/14904/1 "2024-12-11T07:06:33Z")

</div>

I have an image element and when user hits CTRL + V , I need to paste the image in user’s clipboard to the variable thats binded to the src of image.

I am running the workflow using “On keydown” but cant figure out how to capture image data from clipboard and assign it to variable.

I tried js function like this

```auto
navigator.clipboard.readText()
  .then(text => {
    variables['a947901f-9002-4fd7-b3ba-142fc68c464f'] = text;
  });

```

it works for text , but no luck wit himages in clipboard

---

<div class="post-metadata">

**Author:** ![dingan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dingan/32/10624_2.png) [@dingan](https://community.weweb.io/u/dingan)\
**Post date:** [December 11, 2024, 7:35am UTC](https://community.weweb.io/t/paste-image-from-clipboard-to-a-variable/14904/2 "2024-12-11T07:35:20Z")

</div>

Update , this worked.  
Pasting it for anyone who needs it

```auto
navigator.clipboard.read()
  .then(items => {
    for (const item of items) {
      if (item.types.includes('image/png') || item.types.includes('image/jpeg')) {
        item.getType(item.types[0])
          .then(blob => {
            const reader = new FileReader();
            reader.onload = () => {
              variables['a947901f-9002-4fd7-b3ba-142fc68c464f'] = reader.result;
            };
            reader.readAsDataURL(blob);
          });
      }
    }
  });

```

---

<div class="post-metadata">

**Author:** ![Dom](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@Dom](https://community.weweb.io/u/Dom)\
**Post date:** [January 2, 2025, 11:18pm UTC](https://community.weweb.io/t/paste-image-from-clipboard-to-a-variable/14904/3 "2025-01-02T23:18:20Z")

</div>

Hi @dingan, I’m trying something similar but simpler, I just want the contents of the clipboard to be returned in a workflow for further manipulation. It’s just basic text.

I’ve tried navigator.clipboard.readText() and it’s not returning anything. I’ve also tried navigator.clipboard.read() and also nothing.

Note, I’m trying to avoid assigning to a variable, I just want the result returned in the workflow and picked up by a subsequent step.

Any ideas what I’m missing?
