Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Upload all images in current vault #7

Open
Luvata opened this issue May 12, 2021 · 9 comments
Open

Feature request: Upload all images in current vault #7

Luvata opened this issue May 12, 2021 · 9 comments
Assignees

Comments

@Luvata
Copy link

Luvata commented May 12, 2021

I discovered your plugin and I must admit that it's awesome! It's the last missing part to make my notes lightweight but also keep my vault from being bloated by Screenshots !

But I discovered your plugin a bit late... my current vault already contains ~40 images, so in the future can you add a new feature to upload all images in current vault to imgur, it would be really meaningful for someone like me !

Thank you sooo much for publishing this awesome plugin !

@gavvvr
Copy link
Owner

gavvvr commented May 12, 2021

Hi @Luvata, I already had this idea in mind and now I see the real request for this.
I agree, it will be very useful for anyone who discovered the plugin and wants to migrate their vaults to make them light-weight.
The feature request is accepted and I will implement it when I have a time.

I can imagine the following 2 approaches:

  • user right-clicks local image and has a context menu item to replace the local image with it's remote copy. This will give a fine-grained control and should be easy to implement, but will require a lot of manual work if you want to migrate the whole vault;
  • user right-clicks a folder (or somehow an area belonging to the root of the vault), presses 'Migrate to Imgur' and receives a preliminary list of images for migration (to review the list and probably uncheck something). When ready, user proceeds and migrates the whole vault at once

Please share your ideas if you have other view

@Luvata
Copy link
Author

Luvata commented May 12, 2021

Hi @gavvvr thank for your quick response. I think why not both? (2) is much faster to migrate indeed but (1) is enough for me currently 😄 Another approach I'm thinking about is a command to quickly toggle an image's source between local and imgur (in edit mode), it's also fast and convenient too

@ih8snow
Copy link

ih8snow commented Jul 16, 2021

Hi,
I just noticed "There is an upload limit of 50 images per IP address per hour." So that maybe a problem, when you upload a larger number of images.
I just did it manually (with authenticaed user) and received strange error messages:

or

When I checked my user account, I saw that I already upload 50 image...so it seems I have to wait until the hour (whatever hour is meanrt here) is over.

Not sure how that will work with large vault...

@gavvvr
Copy link
Owner

gavvvr commented Jul 16, 2021

@ih8snow did you want to paste the "strange error message" to your comment? I can not see it.

I just did it manually (with authenticaed user)

with the browser? Did you know that Imgur plugin itself now supports authentication? (you will need to update to the latest version)

This help page says:

There is an upload limit of 50 images per hour. There is no upload limit per account, so upload to your heart's desire!

I am not sure what last sentence means. It might mean that in general there is no limits on images count per account. But there is a limit in time space (50 images per hour). For both: authenticated and anonymous upload.

Anyway, thank you for sharing this info. With this limit, the migration of the whole vault at once is hard to imagine. But it will still work at least for 50 images per hour which is still better than nothing at all.

@ih8snow
Copy link

ih8snow commented Jul 17, 2021

Hi,

here are the error messages:
<!--Upload failed, remote server returned an error: [object Object]-->
or
<!--Upload failed, remote server returned an error: The access token provided is invalid.-->
(I get this one even in between when I work fast with my copy/paste process.

Yes, I used the plugin with authentification and that what I meant with manually. So went to my pages with local attachements and copied / pasted them ...then I received this error messages and finally found out that I need a different IP if I have more then 50 images per hours.

Thank you for your work on this plugin, makes working with obsidian much easier!

@tomleary
Copy link

Hey, thanks for this wonderful plug-in! It's really helped me a lot.

I'm posting just to say I'm also very interested in being able to upload the images already in my attachments folder. In my specific case, I'm trying to import my Tumblr into Obsidian. I use Tumblr less like a blog and more like a commonplace book, where I find, tag, and post art and quotes that I like. I've been using it heavily for over ten years, so I have over 10,000 posts.

Fortunately, there's already a good Tumblr exporter out there, so the hard part is finished without much hassle. Now, all I have to do is convert the HTML files to Markdown and add the images back in. Currently, I have to go through each Markdown file and copy-paste each image. I have over 13,000 images, so I'd prefer to not have to do that. I'd be over the moon if I could just click a button and have all the pictures in a note converted.

I realize there's a limit of 50 images per IP address per hour, but that's fine by me; I'd prefer to click a button once an hour for 260 hours over manually copy-pasting 13,000 images.

Either way, thanks for your time and effort on this, and have a great day!

@gavvvr
Copy link
Owner

gavvvr commented Nov 13, 2021

Hi @timmyreal. I hope I will have a time to work on uploading already existing images soon. There is some POC code already for uploading a single image with a right-click.
Me, too, wants this feature to exist to attract more users with easy migration of their already existing vaults

@gavvvr
Copy link
Owner

gavvvr commented Nov 16, 2021

Sharing some WIP code which allows to upload a single image with a right-click from editor view:

const clickable = editor.getClickableTokenAt(
editor.getCursor()
);
const lt = parseLinktext(clickable.text);
const file = this.app.metadataCache.getFirstLinkpathDest(
lt.path,
view.file.path
);
const arrayBuffer = await this.app.vault.readBinary(file);
const fileToUpload = new File([arrayBuffer], file.name);
// console.log(blob);
this.uploadFileAndEmbedImgurImage(fileToUpload)
.then(() => view.app.vault.trash(file, true))
.catch((ee) => console.log(ee));

@DryIce1
Copy link

DryIce1 commented Jan 19, 2023

Sharing some WIP code which allows to upload a single image with a right-click from editor view

Hello @gavvvr,
a sincere thanks for the plugin.
I wonder if you have made any progress with the image upload for this plugin?
Or could you tell me how to incorporate the code you posted above? I tried pasting it into the main.js file but despite despite exhausting all of my non-coder capabilities, such as pasting whilst simultaneously crossing my fingers lol, it didn't work.
warm regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants