Fixed Pasting an image into the editor always converts to png attachment

AndyB

Well-known member
Why is it that when we paste a jpg image into the editor it gets converted to a png attachment?

What part of the code does this conversion?

Thank you.
 
Last edited:
This sounds more like a bug since I can reproduce it here aswell.

I'm pretty sure this is by design, hopefully someone from the team can confirm. Also hoping to get a little hint as to where the code is that does the conversion, I looked for a long time but could not find it.
 
I don't think this behaviour has anything to do with XenForo..

In Chrome I get this same behaviour if I copy and paste an image into Gmail when composing a new email/reply (Chrome converts the image into PNG). The only way around it is to of course save the image and manually upload or drag it into the editor..
 
I think this is something which happens within Froala and is likely related to how the raw paste data has to be manipulated into a format that can be uploaded and displayed in the editor. There's a lot of variables here and a lot of different approaches built in to the editor to handle all sorts of edge cases. In some cases, it might be possible for it to detect and retain the original extension, but the assumption is if it doesn't do that then there must be a specific reason for it.

There is no actual conversion of the data in this case. If you upload a jpg file, it will still be a jpg file, but it will just give it a png extension. This is actually sort of similar to how we process avatars - any avatar you upload will be given a .jpg extension.

Ultimately, however, the extension makes very little difference to anything. Browsers, image editors, etc. they don't rely on the extension to decide how to display an image. They know from the internals of the image, the headers and any metadata within the image what the actual image type is.

So to answer your original question (before you edited the first post), no, it isn't better to save it as a jpg. The file you upload will be identical to the one that is saved, regardless of the extension.
 
When I go to the Froala site:

https://www.froala.com/wysiwyg-editor

and paste a jpg image into the editor like this:

1521043822530.webp

I then click the Code View button, I see the image as a jpg.

1521043870776.webp

So it appears Froala is properly adding the jpg extension.

Chris could you double check if XenForo is saving the attachment as a png ignoring the jpg extension.

Thank you.
 
Note, also, that they are using Amazon. I think storing it as such might be related to that.

Nothing further to check. Can you explain why this is causing some sort of issue, or otherwise needs to be changed?
 
Can you explain why this is causing some sort of issue, or otherwise needs to be changed?

I did some more testing and see that Froala is converting the pasted jpg image to a png.

Example if I copy the attached image which is a 1500x1000 248 KB jpg file and paste it into a Froala editor it will convert it to a 1500x1000 2.7 MB png file. It would be better if possible to keep the size and format of the file the same.
 

Attachments

  • yosemite.webp
    yosemite.webp
    179.8 KB · Views: 8
I just checked XF1 which uses the Redactor editor. That editor not only retains the original file format but the original name as well. So it looks like Froala can improve on this issue, I'll reach out to them to see if they have plans on adding the code to keep the original format and file name of pasted images.
 
Just to be clear, we've been using 2.7.6 since before the release of XF 2.0.3 last week.

Did you mean 2.7.7?
 
Had you not attempted to reproduce the issue here previously? Pretty sure we’d been running 2.7.6 for about a week before we released 2.0.3 and 2.0.4. Or were you testing it locally with 2.0.2?
 
Sorry I did not test properly.

The problem has not been fixed and JPG images pasted into Froala always get converted to PNG. I have reported the issue to Froala (Stefan) and will report back here when I get word from him.
 
Back
Top Bottom