Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't paste images into chat #79

Open
emyller opened this issue Jan 10, 2021 · 42 comments
Open

Can't paste images into chat #79

emyller opened this issue Jan 10, 2021 · 42 comments
Labels
help wanted Extra attention is needed upstream Upstream issue

Comments

@emyller
Copy link

emyller commented Jan 10, 2021

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 emyller added the bug Something isn't working label Jan 10, 2021
@xeco23
Copy link
Owner

xeco23 commented Jan 15, 2021

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 xeco23 added good first issue Good for newcomers help wanted Extra attention is needed labels Jan 15, 2021
@vfmatzkin
Copy link

vfmatzkin commented Mar 2, 2021

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.

@xeco23
Copy link
Owner

xeco23 commented Mar 2, 2021

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

@emyller
Copy link
Author

emyller commented Mar 3, 2021

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

@antaxiom
Copy link

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

@CleoMenezesJr
Copy link

Any prediction of when this feature will come?

@xeco23
Copy link
Owner

xeco23 commented May 20, 2021

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
Copy link
Owner

xeco23 commented Jul 9, 2021

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.

@rodrigost23
Copy link
Contributor

rodrigost23 commented Aug 9, 2021

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
Copy link
Contributor

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?

@pempek
Copy link

pempek commented Aug 18, 2021

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.

@xeco23
Copy link
Owner

xeco23 commented Aug 18, 2021

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 xeco23 added upstream Upstream issue and removed bug Something isn't working labels Nov 10, 2021
@ravenlost
Copy link

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 :)

@antaxiom
Copy link

antaxiom commented Nov 15, 2021 via email

@ravenlost
Copy link

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

@SolidCapo
Copy link

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

@xeco23
Copy link
Owner

xeco23 commented Mar 5, 2022

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.

@CleoMenezesJr
Copy link

CleoMenezesJr commented Mar 5, 2022

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.

@SolidCapo
Copy link

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
Copy link

@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 👍

@emanuelserpa
Copy link

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

@mohammad-aqajani
Copy link

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

@serhumanos
Copy link

Hi! Do you think this feature is possible?

@emanuelserpa
Copy link

emanuelserpa commented Sep 28, 2022

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

@xeco23
Copy link
Owner

xeco23 commented Sep 28, 2022

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.

@emanuelserpa
Copy link

emanuelserpa commented Sep 28, 2022

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.

@xeco23
Copy link
Owner

xeco23 commented Sep 28, 2022

Done!

@saozer
Copy link

saozer commented Feb 16, 2023

I think there is an event listener for Paste action. Here is my suggestion
according to my skill in other languages. As I told you last time, I am new with C#. But Truly, there is a Clipboard object in
C#. try to understand the logic bellow

public void TextBox1_Paste(){
    if (Clipboard.ContainsImage()){
           TextBox1.addContent(Clipboard.getImage());
    }
}

There is an Object with image's Methods for clipboard

    Clipboard.ContainsImage(); // return True/false
    Clipboard.getImage(); // get image from clipboard
    Clipboard.setImage(); // put an image in the clipboard

here is a link to How to use the clipboard Class. Clic here to launch!.
But if i try to understand Whatsapp, it is like a mail: you have a message and its attachements. So, may be clipboard's images are like attachements.
According to this new point of view. the code should be like this:

public void TextBox1_Paste(){
    if (Clipboard.ContainsImage()){
           pastePopUp.show();
           pastePopUp.imageList.addImage(Clipboard.getImage());
           GobalMassage_var.addAttachement(Clipboard.getImage());
    }
}

It is not what you expect but in my mind it could look like that

@wokawoka
Copy link

wokawoka commented Mar 8, 2023

I am experiencing the same issue: I can't paste any image o the chat.
I'm on Pop os 21.10 + KDE 5.24.4
I am not experiencing the same problem with other whatsapp clients for linux such as
https://github.com/oOthkOo/whatsapp-desktop
or
https://github.com/WAClient/WALC

@xeco23 xeco23 pinned this issue Jun 27, 2023
@dimisjim
Copy link

dimisjim commented Aug 4, 2023

Same issue. Using ubuntu 23.04 with wayland

@eduxapo
Copy link

eduxapo commented Aug 8, 2023

same issue using manjaro arch with xorg

@WaxArsatia
Copy link

is this solved yet?

@tom-james-watson
Copy link

Please just give the issue a thumbs up if you also want this to be fixed. Adding a "+1" / "Any updates?" comment and notifying everyone in the thread is not useful. If there were updates they would be posted here.

@emanuelserpa
Copy link

emanuelserpa commented Aug 16, 2023

This issue is a WebKitGTK bug and the "fix" is installing a patched webkitgtk like webkit2gtk-imgpaste

@bayazidbh
Copy link

On AUR, that would have to be handled by the user, yes. But is it not possible to ship that version of webkit2gtk in platforms like Flatpak, Snaps, and Nixpkgs?

@edugmes
Copy link

edugmes commented Sep 27, 2023

Have you guys found any solution? I have it currently installed on Ubuntu 22.04.

@fwosar
Copy link

fwosar commented Dec 9, 2023

On AUR, that would have to be handled by the user, yes. But is it not possible to ship that version of webkit2gtk in platforms like Flatpak, Snaps, and Nixpkgs?

It should be possible to ship the patched version in containerized formats like Flatpaks. I guess nobody wants to package it though.

@ericoudesu
Copy link

Still no solution in 2024 ?

@luispresuelgit
Copy link

Don't understand the webkit bug discussion, but that shouldn't affect when copying from desktop env instead of the web borwser copying, right?

Let me explain my scenario: I use KDE plasma with Spectacl, with it, I take a custom screenshot size, then click "copy image to clipboard" button then I try to just "CRTL + V" into Whatsapp for Linux client and nothing happens.

I have to use an external tool like Kolour Paint to save it into my files (I most of the cases I don't want to save it) and then send it as an attachment. This is not an issue in Windows version of the client.

Please, if don't leave this issue unresolved in 2024

@timwassenburg
Copy link

I was running in the same issue, after Googling and reading this topic I removed Whatsapp for Linux and replaced it with ZapZap, problem solved.

@DaviMedrade
Copy link

I was able to fix this in my system (Ubuntu 24.04) by rebuilding the webkit2gtk packages with the imgpaste patches. I'll describe how I did it, but this is not a viable solution/workaround for the project as a whole. This requires running commands in the terminal and customizing system packages, which might affect other programs that use webkit2gtk.

That's why I won't go into more detail: if this is not enough for you to figure out the details on your own, you probably shouldn't be messing with it.

Anyway, first I enabled source code repos for Ubuntu packages, then I ran apt source libwebkit2gtk-4.1-0 to download the webkit2gtk source code in the specific version and with the config files and customizations used to build the official Ubuntu packages. In my case, it downloaded webkit2gtk 2.44.2.

I entered the webkit2gtk-2.44.2 directory that apt source created and ran sudo apt build-dep ., which installs all the dependencies required to build the binary packages provided by the source package in the current directory.

In the webkit2gtk-imgpaste page in AUR, below the “Dependencies” section, there is the “Sources” section, with four files. Two of them are webkit2gtk sources, not needed because apt source already obtained and set up the correct version of the sources, and the other two are the patches (EnlargeObjectSize.patch and PasteBoardGtk.patch), which I saved into the debian/patches directory of the webkit2gtk sources. In that directory there is the series file, which is a text file containing the list of patch files to apply. I just added the names of both patch files to the end of the list and saved it.

From that point on, all I had to do was make sure that I had the basic set of packages needed to build .deb packages, and follow the regular process to build binary .deb packages, which is essentially running two commands:

  • dch -i, which adds a new section in the proper format and with an increased version number at the top of the changelog file then opens it in an editor so you can describe your changes (I just wrote “Added imgpaste patches.”, saved the file, and closed the editor; if you close the editor without saving any changes to the file then the changes made by dch -i are reverted).
  • debuild -us -uc -b -j5, which actually builds the binary packages. The -j option specifies up to how many source files to compile simultaneously. My PC has 6 physical cores, so I told it to use five so I could continue to use the machine to do some light web browsing without it hiccuping all the time because the build process was trying to use all of its processing power. Note: this step takes several hours to complete. My Intel 8th-gen Core i7 (6 cores with hyper-threading), with 32 GB of RAM and both the OS and the webkit2gtk sources on an NVMe SSD, takes about eight hours to build webkit2gtk. If for some reason the build is interrupted, it's possible to resume it from where it stopped by not running dch -i again, and adding the -nc option to the debuild command, which tells it not to run make clean before starting the build process.

Once the build was finished, I left the webkit2gtk source directory (the .deb packages are saved outside of their source directory by default) and installed all the packages (replacing the ones already installed) with sudo dpkg -i *.deb.

That fixed this problem in whatsapp-for-linux. All I have to do now is keep watch over the webkit2gtk page on the Ubuntu packages website and repeat this whole process every time the official webkit2gtk packages are updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed upstream Upstream issue
Projects
None yet
Development

No branches or pull requests