Randomly name images uploaded with clipboard

Hey !

It’s been a week I’ve discovered XWiki and I wanted firstly to thank developpers for such amazing tool.

There is just a tiny behaviour that blocks me from fully document my work. When you past a screenshot into a wiki blank page, it takes the __fileCreatedFromDataURI__.png filename, meaning that I can’t upload another screenshot because it is overwriting the previous one, since it’s taking the same filename.

It would be awesome to have a filename randomizer or a way to upload multiple screenshot without manually changing its name.

Thank you,

That looks wrong. Could you provide some more details: what editor are you using, the version of XWiki you’re using and more generally a detailed list of steps that someone can use to reproduce?

FTR, I’ve just tried this in the standalone wysiwyg editor, in XWiki 14.10.3 and it worked fine:

Screenshot 2023-01-14 at 14.39.36

Screenshot 2023-01-14 at 14.39.55

Thanks

Hi ! Thanks for your answer.

I’m using xWiki Debian 14.10.2 (tomcat + postgresql) with the default editor (wysiwyg).
I’ve been able to push my test further since my post and it is a bit confusing since I can’t tell what are the details that make it happen. Here an example of what I’ve done this morning:

In the sandbox editor, I can actually copy and paste images from clipboard using screenshots (I’m using greenshot but it is doing the same with the default Windows screenshot utility). I’m going into sandbox, clic modify, and can upload images taking names in a correct way.

But then, I’m going into my documentations, create a new page or edit an existant one. Then I’m using windows + shift + S for selecting an area to screenshot, then past it into the editor. The upload works great, but this name is attributed to each file.
I’m using the exact same steps than in the sandbox.
image

And also, I had to make it twice because it has acted normally the first time I’ve done the steps above.

I know this is a pain to debug because it doesn’t occur each time. Please let me know if there is anything else I can do.

Thanks,
Marius

See Loading... for a related problem, and Adding images per drag&drop or from clipboard in CKEditor fails - #17 by mleduc for a related discussion.

1 Like

Hey !

Yes, this problem (Loading...) looks like the steps I’ve done in my server.

Is there anything I can do ?

I can confirm this issue. XWiki 14.10.3 (docker, tomcat + postgresql, german language)

Pasting screenshot from clipboard in WYSIWYG always generates the same filename and replaces the previous screenshot.

grafik

__fileCreatedFromDataURI__.png is created by Chrome and grafik.png is from Firefox.

I noticed this behavior after updating from 14.10.2 to 14.10.3. I few weeks ago it generates filenames like this:

grafik

Thank you for your reports. To keep you posted, we have identified the root cause of the problem and I am in the process of fixing it. The fix will be available in XWiki 15.0RC1 and 14.10.4.

Sorry for the inconvenience.

1 Like

Just updated to the latest lts version. In chrome the pasted images got individual names like 1675430694385-441.png.

But in firefox the problem still exists. Pasting a screenshot from clipboard always generates a file named grafik.png and overwrites the previous one.

grafik

Thanks for testing. What’s the locale of your computer?

German os, browser and XWiki.

I’ve switched my OS (Ubuntu), Browser (Firefox) and Wiki to German without reproducing.
Can you tell me you OS and the software you used to copy the image to the clipboard? That will help me to figure out where the “grafik” keyword is initialized.

OS is win 11. browser is firefox dev edition 110.0b9.
I tried Lightshot, the “windows snipping tool” and just pressing the “print” key on the keyboard… All methods create a “grafik.png”.

Thanks. May I ask you to create an issue on jira.xwiki.org with all those details?

I already found an open issue for this problem: Loading...

1 Like

Based on this issue ckeditor4#664 i’ve created a workaround.

Just add the following to the global configuration for CKEditor:

CKEDITOR.on('instanceReady', function(event){
	let originalCreate = event.editor.uploadRepository.create;
	event.editor.uploadRepository.create = function(file, name) {
		let defaultFileName = event.editor.config.fileTools_defaultFileName;
		if (!name && file && file.type === 'image/png' && file.name === 'grafik.png' && defaultFileName) {
			name = defaultFileName + '.png';
		}
		return originalCreate.call(this, file, name);
	};
});

It enables the default filename handling, when the file is called “grafik.png”. As you can read in the comments at the jira issue CKEDITOR-337, CKEditor wants a “image.png” and is getting the localized version “grafik.png”.
So this workaround might only working on german systems. For other languages the “grafik.png” needs to be replaced with your localized version of “image.png”.

Hey, just updating for my personnal case.
I’ve been waiting for the release of the LTS 14.10.4. Just updated and it seems to be working for me.
Using firefox stable (french).
I’d like to be sure with a week of usage tho.

Thank you,
Marius

Are you using Firefox stable on windows?

Yes, using 109.0.1(64 bits) french on Windows

Ok, I will check on a colleagues computer tomorrow. For me, both (stable and dev edition) of Firefox on windows, creates the “grafik.png” and replaces it everytimes.

Hey, coming back on my previous message. It looks like the problem still appears. Not everywhere tho because I tested it on the sandbox and it was working fine.
But still the same when creating a new page or editing an existent one.
image