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

Thumbnail previews for Vivaldi html images #1591

Closed
echometerain opened this issue Feb 17, 2021 · 5 comments
Closed

Thumbnail previews for Vivaldi html images #1591

echometerain opened this issue Feb 17, 2021 · 5 comments

Comments

@echometerain
Copy link

echometerain commented Feb 17, 2021

Describe the bug
In Vivaldi (and chromium I believe), the "copy image" function does not copy the actual image but an instead copies an html file embedding the image.

For example, the image https://cdn.pixabay.com/photo/2018/03/19/15/04/wet-3240211_1280.jpg will copy as <meta http-equiv="content-type" content="text/html; charset=utf-8"><img src="https://cdn.pixabay.com/photo/2018/03/19/15/04/wet-3240211_1280.jpg"/> instead, which most applications (including github) accepts. But for these "images", copyq doesn't generate thumbnail previews

To Reproduce
Steps to reproduce the behavior:

  1. Copy an image on Vivaldi

Expected behavior
copyq could either download the image component of the html file and store it, or copyq could continue its current behaviour but with generating and storing thumbnail previews.

Screenshots
image
image

Version, OS and Environment
(Get details from copyq version command if possible.)

  • Copyq v3.13.0
  • Manjaro GNU/Linux
  • KDE Plasma with kwin
@hluk
Copy link
Owner

hluk commented Feb 20, 2021

This is not a bug. CopyQ won't fetch any remote content unless you specify such action with a custom command. So if the web browser does not provide an image format, you won't see the image in CopyQ.

I'm against adding such feature due to security and performance concerns, and TBH I don't need such behavior because most of I use copy images to clipboard properly.

@hluk hluk removed the bug label Feb 20, 2021
@SMSourov
Copy link

SMSourov commented Nov 29, 2021

@hluk Ok!

This is not a bug. CopyQ won't fetch any remote content unless you specify such action with a custom command. So if the web browser does not provide an image format, you won't see the image in CopyQ.

I'm against adding such feature due to security and performance concerns, and TBH I don't need such behavior because most of I use copy images to clipboard properly.

By this comment, I'm guessing that you won't add this feature. Can you show an example to set a custom command? I do need this feature. No matter which browser I use, It shows only the metadata.
image

@hluk
Copy link
Owner

hluk commented Dec 1, 2021

By this comment, I'm guessing that you won't add this feature. Can you show an example to set a custom command? I do need this feature. No matter which browser I use, It shows only the metadata.

Check what formats the clipboard provides after copying an image (with Ctrl+Shift+C in the main window in CopyQ) and then create a new automated command in CopyQ to download image data. Example (untested):

copyq:
// Change the input format (from clipboard)
var imageUrl = str(data('text/plain'))
if (!imageUrl.startsWith('https://') || !imageUrl.includes('.png'))
    abort()

var reply = networkGet(imageUrl)
var imageData = str(reply.data)
if (reply.status != 200) {
    throw 'Failed to fetch image data.'
        + '\nStatus code: ' + reply.status
        + '\nError: ' + reply.error
}

// Change the output format
copy('image/png', imageData)

BTW, Firefox provides copied images properly in the clipboard.

@NA0341
Copy link
Contributor

NA0341 commented Jul 3, 2023

@hluk said:

This is not a bug. CopyQ won't fetch any remote content unless you specify such action with a custom command. So if the web browser does not provide an image format, you won't see the image in CopyQ.

BTW, Firefox provides copied images properly in the clipboard.

I totally agree that CopyQ shouldn't automatically fetch stuff from the web by default.

But the issue is not the WebBrowser!
I've added info to this issue #2084 which shows that Vivaldi (in this case) provides the image data necessary to store the image - but CopyQ does not store it!

@rod-stuchi
Copy link

I've changed a little what @hluk did above, and its working for me

[Command]
Automatic=true
Command="
    copyq:
    var imageUrl = str(data('text/plain'))
    serverLog(\"info:: url: \" + imageUrl)

    if (!imageUrl.startsWith('https://')) {
        abort()
    }

    var reply = networkGet(imageUrl)
    if (reply.status != 200) {
        throw 'Failed to fetch image data.'
            + '\\nStatus code: ' + reply.status
            + '\\nError: ' + reply.error
    }

    serverLog(\"info:: status: \" + reply.status)
    setData('image/png', reply.data)"
Icon=\xf15b
Name=Fetch Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants