Changing image.png for importing images?

When you paste an image into tw you are presented with a an import dialog and a field with the name “image.png” which you almost always need to change. In my case, I want to have a default like “lesson-22-.png”, where I’ll just add the part after the hyphen. Is there any way to change the default import image name?

Are you using ctrl-v or dragging a filename?

Ctrl-v – from screenshots.

image.png issue discussion: Paste from clipboard · Issue #2807 · Jermolene/TiddlyWiki5 · GitHub

TW can’t control what file name it’s handed, but it can control what file name it will use by default for the import process. So my intent is somewhat different than the one in the GH post.

1 Like

Bump. It’s really inconvenient having to do a half dozen complete renames, especially since the dialog doesn’t let you just click on the field and start editing, but requires an additional hoop/click to a rename dialog.

2 Likes

Mark

I would like to help. Since screenshots tend to be random filenames would you like to just set another base title?

Perhaps a different drop zone?

Personaly I use snagit to screen capture then drag the image perhaps after a minor edit to tiddlywiki. Often I just run with the snagit title. In later versions of tiddlywiki you can drop into the edit and it imports and embeds in the text you are writing. So I place the image as I write so the filename is relavant. With relink plugin you can rename later.

I can think of some features to improve the screen capture workflow. Like a tool listing each image below perhaps with a preview and the ability to rename inline?

What are your thoughts?

That’s exactly it. When you paste a copied image into TW, it sets a base title of image.png. It sets that image name even if there already is a file image.png. I think that means that it will ovoerwrite an existing file. So I’m forced to do a rename right there. Which wouldn’t be so bad if it was a little easier to navigate.

What I’m doing is taking screenshots from a video course, and then pasting them into a tiddler between the transcript text from the same course. So getting a reasonably named image pasted into the exact position is pretty important.

I could save a screen shot to a directory and then drag/drop it into position, but that’s extra steps – copying/pasting is a more natural work flow. With Saq’s uploader, the images can later be turned into image files.

So the best solution would be if there was a way to change the base title so fewer keystrokes need to be made when inserting.

Thanks!

1 Like

I will give it some thought. With snagit its editor lists the captures and images can be dragged from it to my wiki without touching the file system. Snagit generates a unique if not friendly name. Once imorted and embeded in my wiki with relink i can rename.

There may be a free snagit or other solution with this intermediate file manager that could help you.

There is no doubt such imports should be given unique names.

To clarify, the filename image.png is set by the browser in the paste event, not by TiddlyWiki. On some browsers, this name is also localized. There is no information included in the event to indicate that this is a browser assigned default filename and not a real filename. This in turn makes it tricky to know if we can override the filename received from the event.

This problem is the reason behind this PR to add a hook allowing plugins to customize the file naming: Add th-readFileCallback hook mechanism by FSpark · Pull Request #6517 · Jermolene/TiddlyWiki5 · GitHub

Another potential core approach that would be more universal is to add in the import UI a checkbox that when checked, never overwrites tiddlers on import and instead adds a suffix to non-unique titles.

2 Likes

I wondered if we could deal with @Mark_S’s use case by hacking together a button that automatically renamed all of the queued subtiddlers in $:/Import using a base string and a sequence number.

@jeremyruston with the way the import mechanism currently works, every subsequent image.png pasted into the wiki would overwrite the previous one queued in $:/Import.

$:/Import cannot contain two pending tiddlers with the same name.

Hence my thinking that for pasted files we can safely assume the title is always a browser generated one and therefore always override it with a custom naming scheme that generates unique titles. Potentially the basename could be set via a config setting. To clarify, this would happen before the tiddler is inserted into $:/Import.

Both Github and Discourse do something similar. You can see in the UI for both that when an image is pasted it is uploaded as image.png, and then made available at a unique URI.

If you are capturing images it is not enough just to ensure unique names are used. There needs to be an opportunity to name or annotate and idealy at the time of import.

I am sure we can make this easier for real world practical use.

That is already possible in the import UI.

Saq do illustrate. I am suggesting it could be better and easier.

I’m not sure what you want me to illustrate, surely you are familiar with the default core affordance for renaming a tiddler in the import UI before import? You can name an image to your liking before import, which is precisely the opportunity you expressed a desire for.

Improvements to the user experience would be very welcome. The entire import UI is wikitext based. It would be very interesting to see a demo of other ideas for a better user experience.

I just tried a few capture and paste of images without using my snagit app to see if there were any issues. There are. Rather than document them here I will take this off line and research the barriers to simple workflows . Being able to paste or drop and have the filename increment, as per the OT here is one improvement, but also other impediments exist to swift capture and use such as you mentioned “$:/Import cannot contain two pending tiddlers with the same name.”

I solved many of the limitations of tiddlywiki workflows for this by using snagit which provides “random unique image names” as I posted previously, but have other ideas such as custom dropzones.

However if anyone has already found a smooth and productive way to do this and can document their workflow it would be helpful.

I think the core already provides plugin authors with everything we need to tackle this problem.

I did an experiment and did add a new function to the bundler plugin, because it already uses a similar feature:

A short test is shown in the following screenshot. Since my FF browser talks German to me, it uses “grafik.png” as the default image name. This name comes from the browser. …

In the test I did hit CTRL-V 6 times within 1 second :slight_smile:

There are 2 config tiddlers:

$:/config/wikilabs/import/image/default-title … which defaults to image.png
$:/config/wikilabs/import/image/title-template … which defaults to: test YYYY-0MM-0DD, 0hh:0mm:0XXX.png

As soon as the “update” function sees: image.png / grafik.png it converts the name into the title-template, which uses the TW standard date format.

Users can define the “input title”, which should be replaced.
Users can define the “output template” which should be used to create the new name.

You only need to take care, that the “output” is unique enough for your workflow.

@Mark_S … Do you think this would work for you?

1 Like

It would be possible to keep “grafik.png” as an unselected tiddler. … But that’s just an implementation detail, which I personally think isn’t necessary.

It also works without any code changes if an image is dropped into a tiddler text area.

Which results in some text like this:

1 Like

@pmario good work. This name serialisation of imported images is a critical minimum behaviour in my view and worthy of a core fix.

Experimenting with real world workflows

  • when an image is dropped into the editor its position has being determined by the author and allows the author to proceed with just a “unique title”.
  • When one or more images are pasted “ctrl-V” at a minimum they need a unique title, however in reality in this situation to make use of the image later we may want to rename the image tiddler even before import so we can find it in future, ideal with minimum key strokes.

Perhaps if the import process, or let us consider the subset of paste based “imports” for which we have no file/tiddler name. It would be great if we could click edit the title, and ideally also see an image/content preview before (or less desirably shortly after import).

  • One could past a bundle of images and content into a wiki import process and never import it, but drag the “import bundle” to another wiki.