whatsapp-for-linux icon indicating copy to clipboard operation
whatsapp-for-linux copied to clipboard

Can't paste images into chat

Open emyller opened this issue 4 years ago • 42 comments

Description Having the chat text box focused, one can't paste images from the clipboard in it. For now, the user has to attach an image and select one from the file system.

To Reproduce Steps to reproduce the behavior:

  1. Copy some image content to the clipboard, e.g. a screenshot.
  2. Open a chat and focus on the text box.
  3. Paste the contents, nothing happens.

Expected behavior The client should accept the contents from the clipboard and display a preview for the image, allowing to add a description, etc -- a WhatsApp feature, I believe.

Screenshots image

Environment

  • Arch Linux
  • AUR

emyller avatar Jan 10 '21 20:01 emyller

Hi @emyller. Normally, if I copy the path from my file manager, it works. Could you tell me how do you copy and what you get when you paste it to another text area i.e. your browser's search bar?

xeco23 avatar Jan 15 '21 11:01 xeco23

Hi, I found this issue when I experienced this problem. Another example is when copying an image displayed in the web browser (like this one) via the right click->copy image, and trying to paste it in whatsapp-for-linux.

Normally, a text field shouldn't display anything when pasting this img copied contents, but if it supports images (as whatsapp web), it should load the image. Anyway, sometimes (I don't remember exactly where) when pasting the image in a text field, a base64 encoding of the image may appear.

vfmatzkin avatar Mar 02 '21 12:03 vfmatzkin

@vfmatzkin Thanks a lot, makes sense. So, it doesn't work with the images copied into memory I guess, not with image paths.

xeco23 avatar Mar 02 '21 18:03 xeco23

@eneshecan Sorry, I forgot to reply to your first message. @vfmatzkin Thank you for adding the context!

emyller avatar Mar 03 '21 00:03 emyller

Any updates on this? I need this feature frequently and end up opening it on my browser far too much.

antaxiom avatar May 14 '21 11:05 antaxiom

Any prediction of when this feature will come?

CleoMenezesJr avatar May 20 '21 04:05 CleoMenezesJr

Unfortunately not soon as I am not fully available until the end of June. Sorry for the inconvenience... I think it requires a bit of work involving handling some clipboard data in webkit2gtk but I didn't have a chance to look closely. If someone tries to do it, I can review and merge.

xeco23 avatar May 20 '21 21:05 xeco23

Here I tried to do this in a separate branch, yet without success. https://github.com/eneshecan/whatsapp-for-linux/tree/feature/paste_image_buffer. Any help is appreciated.

xeco23 avatar Jul 09 '21 19:07 xeco23

I just tried the following JavaScript code in both WhatsApp-for-Linux and Firefox:

document.onpaste = function (event) {
    console.log(event);

    var items = (event.clipboardData || event.originalEvent.clipboardData).items;

    for (var index in items) {
        var item = items[index];
        if (item.kind === 'file') {
            var blob = item.getAsFile();
            var reader = new FileReader();
            reader.onload = function (event) {
                console.log(event.target.result);
            }; 
            reader.readAsDataURL(blob);
        } else {
            console.log(item);
        }
    }
};

When pasting an image in Firefox, the event.clipboardData.items contains one item. In WhatsApp for Linux, this object is empty, even though the event gets fired. When pasting text, it works perfectly.

Apparently, that is the event WhatsApp Web uses to get a pasted image.

EDIT: Epiphany also doesn't support this.

rodrigost23 avatar Aug 09 '21 15:08 rodrigost23

Relevant issue from Tangram: sonnyp/Tangram#103. Relevant bug from WebKit's BugZilla: https://bugs.webkit.org/show_bug.cgi?id=218519

Apparently this needs to be fixed by WebKit then?

rodrigost23 avatar Aug 09 '21 17:08 rodrigost23

Related to this issue, I also want to add that it seems like copying image from WhatsApp for Linux doesn't seem to work.

I tried copying an image from WhatsApp for Linux and pasting it to other chat apps (Telegram, Slack), doesn't work.

I can confirm that I'm able to do this on Telegram and Slack by copy pasting images from the internet browser.

pempek avatar Aug 18 '21 07:08 pempek

Relevant issue from Tangram: sonnyp/Tangram#103. Relevant bug from WebKit's BugZilla: https://bugs.webkit.org/show_bug.cgi?id=218519

Apparently this needs to be fixed by WebKit then?

Seems like it. Maybe there are some workarounds we can apply but until then, this seems to be on their side.

xeco23 avatar Aug 18 '21 21:08 xeco23

Hi guys. No actual updates / workarounds for this issue yet ? I copy/paste screenshot images all the time for work purposes and definitely do not want to have to save all images on hdd before sending over... This problem makes me have to use the web version of whatsapp, which I dislike a lot... Any progress on this would be great! Cheers for the status update and time with this :)

ravenlost avatar Nov 15 '21 10:11 ravenlost

I don't really have a solution for you, but I currently run chromium with the --app flag as a way to sort of have whatsapp as a separate browser.

On Mon, Nov 15, 2021 at 6:01 AM ravenlost @.***> wrote:

Hi guys. No actual updates / workarounds for this issue yet ? I copy/paste screenshot images all the time for work purposes and definitely do not want to have to save all images on hdd before sending over... This problem makes me have to use the web version of whatsapp, which I dislike a lot... Any progress on this would be great! Cheers for the status update and time with this :)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/eneshecan/whatsapp-for-linux/issues/79#issuecomment-968724066, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJRW3AS7RMXLEF7GOF4ROETUMDK6XANCNFSM4V4V7SCQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

antaxiom avatar Nov 15 '21 12:11 antaxiom

Ok, thanks for the update. I'll look into doing something like that for now.

ravenlost avatar Nov 15 '21 16:11 ravenlost

Hi, any progress on this? hope it can be done soon...would appreciate it a lot! cause it's even more important than videocalls i think :) You can do it! :D

SolidCapo avatar Feb 22 '22 16:02 SolidCapo

Just checked epiphany if it does work there since they use webkit2gtk too. Unfortunately, it's the same situation. I tried a couple of things as well but I am out of solutions right now.

xeco23 avatar Mar 05 '22 22:03 xeco23

I believe this issue should be closed. This problem is related to WebkitGTK as we can see here. In my humble opinion I suggest either creating an initiative for a workaround or making the problem visible so that more people can contribute directly to WebKit.

CleoMenezesJr avatar Mar 05 '22 22:03 CleoMenezesJr

Well, meanwhile, searching found a very good solution that can do the paste images from clipboard for whatsapp, it's called Ferdi - https://getferdi.com/ and now i'm happy cause i can have all the messengers in one place :)

SolidCapo avatar Mar 10 '22 20:03 SolidCapo

@SolidCapo Thanks! Recently some issues made me abandon Franz, and start using whatsapp-for-linux instead, but Ferdi looks like a good replacement for Franz indeed.

Sadi58 avatar Mar 13 '22 11:03 Sadi58

@SolidCapo Thanks! Recently some issues made me abandon Franz, and start using whatsapp-for-linux instead, but Ferdi looks like a good replacement for Franz indeed.

I think it will help you too, the only thing i hope one day will be available, are the videocalls in whatsapp and messenger :+1:

SolidCapo avatar Mar 14 '22 07:03 SolidCapo

Would be cool if we had something like this in AUR: https://github.com/ttys3/archlinux-webkit2gtk

emanuelserpa avatar Apr 06 '22 18:04 emanuelserpa

install on Ubuntu with snap, also having problem pasting images and files!!!

mohammad-aqajani avatar Apr 13 '22 06:04 mohammad-aqajani

Hi! Do you think this feature is possible?

serhumanos avatar Sep 24 '22 19:09 serhumanos

Hi! Do you think this feature is possible?

This is a problem with WebKit that strangely wasn't solved for a long time, even though it has a patch that solves it.

https://aur.archlinux.org/packages/webkit2gtk-imgpaste

emanuelserpa avatar Sep 28 '22 13:09 emanuelserpa

I don't want to depend on that aur package instead of the stable one. If someone wants to create a different package depending on the fixed aur version i.e. whatsapp-for-linux-imgpaste, please welcome.

xeco23 avatar Sep 28 '22 21:09 xeco23

I don't want to depend on that aur package instead of the stable one. If someone wants to create a different package depending on the fixed aur version i.e. whatsapp-for-linux-imgpaste, please welcome.

I don't think you need to do that, the AUR package already provides webkit2gtk. But I think this info would be cool to have this info in a pinned comment in the AUR package page.

emanuelserpa avatar Sep 28 '22 21:09 emanuelserpa

Done!

xeco23 avatar Sep 28 '22 21:09 xeco23