MyBB Community Forums

Full Version: Image paste from clipboard broken
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

just installed myBB on our server. First thing I tested was image paste from the clipboard ... but this seems to be broken. Is this a known issue? I couldn't find it in the forum or on github.
Short description:
  • Paste image works in the editor, but displays as source code in the preview and in the final posted version

If its not a known issue, I'm happy to provide more details.

Jan
Hi,

This is a known issue as far as I know. I'm not sure if there's a planned fix in the pipeline for now though I'm afraid.
(2016-06-29, 08:55 AM)Euan T Wrote: [ -> ]Hi,

This is a known issue as far as I know. I'm not sure if there's a planned fix in the pipeline for now though I'm afraid.

Hi Euan,

I would be willing to try fixing it if someone can point me in the right direction (where is the issue being tracked? What is the problem about fixing it? Where do I find the relevant source code file)?

Jan
image needs a source file
file should be available somewhere or image needs to be converted to data code

how do we expect image from clipboard to be shown ?
( IIRC, some other forum system converts image to data code & stores it in database .. )
(2016-06-29, 09:08 AM)Jan Rheinländer Wrote: [ -> ]
(2016-06-29, 08:55 AM)Euan T Wrote: [ -> ]Hi,

This is a known issue as far as I know. I'm not sure if there's a planned fix in the pipeline for now though I'm afraid.

Hi Euan,

I would be willing to try fixing it if someone can point me in the right direction (where is the issue being tracked? What is the problem about fixing it? Where do I find the relevant source code file)?

Jan

Hi,

The issue is being tracked here: https://github.com/mybb/mybb/issues/2440

We need to intercept the paste from the editor, to see that it's an image being pasted. I'm not sure if SCEditor (the editor we use) raises any kind of event for this or has a callback (if not, we need to open an issue there, but there haven't been any updates on that project in a very long time now and the primary contributor seems to have disappeared).

Once we intercept the image being pasted, the easiest thing to do is to probably create an attachment, which will need to be done via AJAX. That means a new action will be needed in xmlhttp.php to receive the data, create an attachment and return its ID to be associated with the new post.

It's a fairly large (and complex) issue which is why there's been nothing done about it up to now. It'll need a lot of testing too to ensure it works for multiple image formats. When it's come up before, I think the consensus has been that pasting images into the editor should be blocked in some way to prevent it from happening.
(2016-06-29, 09:21 AM).m. Wrote: [ -> ]image needs a source file
file should be available somewhere or image needs to be converted to data code

how do we expect image from clipboard to be shown ?
( IIRC, some other forum system converts image to data code & stores it in database .. )

It would seem that myBB does just that: When I hit the preview button I see

[img]data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAK etc. etc.

So it looks as though what's wrong is that the data contained in the [img] tag needs to be properly interpreted.

And probably it would be good to enforce an upper limit on image size...

For larger images, the solution to create an attachment via AJAX as described by Euan would be best.

(2016-06-29, 09:39 AM)Euan T Wrote: [ -> ]
(2016-06-29, 09:08 AM)Jan Rheinländer Wrote: [ -> ]
(2016-06-29, 08:55 AM)Euan T Wrote: [ -> ]Hi,

This is a known issue as far as I know. I'm not sure if there's a planned fix in the pipeline for now though I'm afraid.

Hi Euan,

I would be willing to try fixing it if someone can point me in the right direction (where is the issue being tracked? What is the problem about fixing it? Where do I find the relevant source code file)?

Jan

Hi,

The issue is being tracked here: https://github.com/mybb/mybb/issues/2440

We need to intercept the paste from the editor, to see that it's an image being pasted. I'm not sure if SCEditor (the editor we use) raises any kind of event for this or has a callback (if not, we need to open an issue there, but there haven't been any updates on that project in a very long time now and the primary contributor seems to have disappeared).

Once we intercept the image being pasted, the easiest thing to do is to probably create an attachment, which will need to be done via AJAX. That means a new action will be needed in xmlhttp.php to receive the data, create an attachment and return its ID to be associated with the new post.

It's a fairly large (and complex) issue which is why there's been nothing done about it up to now. It'll need a lot of testing too to ensure it works for multiple image formats. When it's come up before, I think the consensus has been that pasting images into the editor should be blocked in some way to prevent it from happening.

If SCEditor is not being actively developed any more, is there any point in fixing issues with it? I saw that there are several Plugins offering other editors (Quick advanced editor, Rin editor, etc.).
(2016-06-29, 09:49 AM)Jan Rheinländer Wrote: [ -> ]
(2016-06-29, 09:21 AM).m. Wrote: [ -> ]image needs a source file
file should be available somewhere or image needs to be converted to data code

how do we expect image from clipboard to be shown ?
( IIRC, some other forum system converts image to data code & stores it in database .. )

It would seem that myBB does just that: When I hit the preview button I see

[img]data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAK etc. etc.

So it looks as though what's wrong is that the data contained in the  [img] tag needs to be properly interpreted.

And probably it would be good to enforce an upper limit on image size...

For larger images, the solution to create an attachment via AJAX as described by Euan would be best.

(2016-06-29, 09:39 AM)Euan T Wrote: [ -> ]
(2016-06-29, 09:08 AM)Jan Rheinländer Wrote: [ -> ]
(2016-06-29, 08:55 AM)Euan T Wrote: [ -> ]Hi,

This is a known issue as far as I know. I'm not sure if there's a planned fix in the pipeline for now though I'm afraid.

Hi Euan,

I would be willing to try fixing it if someone can point me in the right direction (where is the issue being tracked? What is the problem about fixing it? Where do I find the relevant source code file)?

Jan

Hi,

The issue is being tracked here: https://github.com/mybb/mybb/issues/2440

We need to intercept the paste from the editor, to see that it's an image being pasted. I'm not sure if SCEditor (the editor we use) raises any kind of event for this or has a callback (if not, we need to open an issue there, but there haven't been any updates on that project in a very long time now and the primary contributor seems to have disappeared).

Once we intercept the image being pasted, the easiest thing to do is to probably create an attachment, which will need to be done via AJAX. That means a new action will be needed in xmlhttp.php to receive the data, create an attachment and return its ID to be associated with the new post.

It's a fairly large (and complex) issue which is why there's been nothing done about it up to now. It'll need a lot of testing too to ensure it works for multiple image formats. When it's come up before, I think the consensus has been that pasting images into the editor should be blocked in some way to prevent it from happening.

If SCEditor is not being actively developed any more, is there any point in fixing issues with it? I saw that there are several Plugins offering other editors (Quick advanced editor, Rin editor, etc.).

Well, there's no chance that we'll be changing editors in the 1.8.x series due to the amount of effort that would require for users to update (and theme designers, and plugin developers). Right now we're stuck with SCEditor until 2.0 comes out. Some patches are being merged by another user who has write access to the repository, I just wouldn't expect any major fixes for now.
Hi,

I tweaked RinEditor to enable image paste from clipboard and image drag+drop. If anybody is interested in the details I will post them in a new thread.

Jan
^ yes, please post the guidance at Tutorials Section