Jump to content

Paste image to images field?


bernhard
 Share

Recommended Posts

For my personal website I need to add many screenshots. I'd like to just save them to the clipboard and add them to my site by pasting it from the clipboard.

I know that this is possible in CKE and I guess also in TinyMCE but I want to upload these images directly to an images field. Is that possible? I thought I've seen something like this once, but I couldn't find anything. Also it would be nice to be able to upload images from URL. That's especially handy when migrating content from old sites to new ones. But while writing I realise that for that use case a copy paste feature would also help!

Thx

  • Like 1
Link to comment
Share on other sites

I believe what you are looking for is ImportExternalImages - which was designed to allow a user to cut and paste a blog article from another platform like Blogger into a specified text area and then have PW bring in the assets from the URLs that were pasted into a field you set up in config.

https://processwire.com/modules/import-external-images/

  • Like 1
Link to comment
Share on other sites

Thx! Not exactly 🙂 I just want to create a screenshot and then paste that quickly to my blog. But I want to paste it into an Images field rather then to a WYSIWYG field, because there I have more control over what happens on rendering (eg automatically resize and style it and link the high-res version as a lightbox).

Link to comment
Share on other sites

I'm not sure I understood your requirements correctly either. Nevertheless, here's a hint, although I'm pretty sure that's not what you meant. 

I think that currently only applies to CKE. 
In the editor field under input you have the possibility to select an image field that will be used for drag&drop (does also work for pasting an image from clipboard). 

(Screenshot only in German right now)

image.thumb.png.6cd8684fb3535b87b2e5f2979c5fcf1c.png

Link to comment
Share on other sites

I suspect this shouldn’t be too hard to implement naively, but it’s probably non-trivial to get all the configurable bells and whistles to work that image fields support (like client side resizing for example).

I think you can grab images from the clipboard as blobs by listening to the paste event and filtering by type pretty easily. You’d have to figure out which image field to use, since a page could have multiple, and how to interface with it.

I agree CTRL+Ving images is delightful and a desirable feature to have! Personally I don’t like WYSIWYG editors, so a cool feature would be the ability to paste pics into a Markdown textarea and have it upload it and generate the code automatically, like we see on Github.

  • Like 1
Link to comment
Share on other sites

Something like that ? I remember i had started to implement the feature in the not finished module editorjs. I can put my hand on it if you want, it shouldn't be missing lot of work as the upload between the two inputfields is still working..

Click "copy" button on the first pasge, CTRL/COMMAND+V on the second.

 

 

Edit: I must admit that this feature could be handy in the core image things.

Edited by flydev
  • Like 1
Link to comment
Share on other sites

It's interesting how many seem to not understand me 😄 I'll try it again! Thx for asking back!

First of all Thx @flydev for the screencast. I'm not sure I understand that as it seems to be cropped and also I don't really get why the pasted image is in the footer at the end?!

5 hours ago, Jan Romero said:

I suspect this shouldn’t be too hard to implement naively, but it’s probably non-trivial to get all the configurable bells and whistles to work that image fields support (like client side resizing for example).

True

5 hours ago, Jan Romero said:

I think you can grab images from the clipboard as blobs by listening to the paste event and filtering by type pretty easily. You’d have to figure out which image field to use, since a page could have multiple, and how to interface with it.

I agree CTRL+Ving images is delightful and a desirable feature to have! Personally I don’t like WYSIWYG editors, so a cool feature would be the ability to paste pics into a Markdown textarea and have it upload it and generate the code automatically, like we see on Github.

True! Well it doesn't necessarily have to be CMD+V as you are right, it would be hard to tell which image field to target. Maybe a button to click would be easier/better. Maybe that could only appear if a suitable image is available in the clipboard.

6 hours ago, androbey said:

I think that currently only applies to CKE. 
In the editor field under input you have the possibility to select an image field that will be used for drag&drop (does also work for pasting an image from clipboard). 

(Screenshot only in German right now)

image.thumb.png.6cd8684fb3535b87b2e5f2979c5fcf1c.png

Thx - I already tried to explain that I'm not talking about the CKE field but a single core image upload field. But technically that shows that it's possible and we have the pieces already in the core. They would just have to be applied a little differently.

---

For everybody who still didn't understand my request:

Let's say we created a ticket system. And every ticket has an image field where we can/should upload a screenshot of the issue. Now I open my screenshot app on my laptop and add some arrows, blurs, notes etc. and then I hit "copy to clipboard". Then it would be nice to be able to go to my ticket system and just paste my image into that image field.

I agree that this is really not a lot effort to save the image first and then load it from the PW images field, but those little extra steps add up and sometimes they make the difference whether an app feels easy or tedious to use.

Now

  • make screenshot
  • click save image to disk
  • think about where to save the image, or even worse add some more clicks to find the correct path to save it
  • open processwire and click load image
  • find the correct image path to load the image from
  • hit upload
  • delete the now unnecessary image from your disk

My wish

  • make screenshot
  • click copy image to clipboard
  • open processwire and click paste from clipboard

For me this workflow would really be much better.

Link to comment
Share on other sites

Its copied on the bottom because its an example of a feature not finished on another (not really) WIP module.

it does what you are talking about. Copy image from another field, or from a screenshot, it doesnt matter, I understood you was talking about « clipboard ».

Quote

Its copied on the bottom because its an example ..

The specific reason is as you are limited on mimetypes when working with the clipboard write api, in the example above it render the blob in a canvas, on différent format, including webp.

Voila 🙂 

Edited by flydev
  • Like 1
Link to comment
Share on other sites

Did you try snippets in Windows?  No need to save, it is automatically put in the screenshots folder which you keep open, so just snapshot it, edit as required and drag. When done, delete all the contents of your folder. Ok so that’s one more step than ideal, but at no development effort!

Link to comment
Share on other sites

Thx for that reminder @MarkE my screenshot tool on mac actually also has the feature to open the screenshots folder directly 🙂 Well, it's just about preference I guess and initially I was just asking if there is already a solution for that - then it would also be no development effort 😉 

But still I think it would be nice if the core images field would support that for situations where you simply have something at hand in the clipboard and it would take some extra steps otherwise.

For example from any website you could then just rightclick on the image and then paste it to the field. Now you'd have to "save image as..." and then upload it. Not a big deal, but still annoying for me 🙂 

Link to comment
Share on other sites

The problem here is (potentially) three-fold, depending on (others') needs:

  1. If it's supported in a Pageimage field, it's likely expected to also be supported in a Pageimages field (WireArray) which adds some awkward complexity, because...
  2. We can have multiple image fields per template - we'd have to determine focus prior to pasting for this to work properly, whether a button is clicked (and it just attempts to pull from the clipboard) or a some sort of area gains focus, and then we paste...
  3. As flydev mentions, we're limited in the filetype that we can save as - and simultaneously if there's a developer preference should it be predetermined, or do we just go with whatever the OS provided as default?

What you might be thinking about is this forum's ability to paste an image as a file attachment, but it is essentially using CKE to handle that; otherwise, I only really remember Robin's module as a way to paste URLs of a file (and not just a data: URL, though it might be able to be modified to handle that).

I've handled clipboard image pasting before, but I've never handled multiple images (files) within a single clipboard instance. That's outside your described scenario, to a degree, but drag-and-drop supports multiple files, so should copying multiple existing files and pasting also similarly work in this example?

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...