Skip to content

Intercept image paste #35

Closed Answered by masudhossain
masudhossain asked this question in Q&A
Discussion options

You must be logged in to vote

In case anyone else is wondering how to intercept large base64 image pastes so it doesn't destroy your load time and how much data is in your state.

Take the array in content to create an image using that base64.

const handlePaste = (event) => {
    const clipboardData = event.clipboardData //|| window.clipboardData;
    
    console.log(clipboardData)
    if (clipboardData && clipboardData.items) {
      for (let i = 0; i < clipboardData.items.length; i++) {
        const item = clipboardData.items[i];

        if (item.type.indexOf("image") !== -1) {
          const imageBlob = item.getAsFile();

          // Create a URL for the image blob
          const imageUrl = URL.createObjectURL(i…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@masudhossain
Comment options

@megahertz
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by masudhossain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #34 on December 13, 2023 06:03.