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 : Download all the Imgur links and replace them with local images (and vice-versa) #10

Open
Raagaception opened this issue May 20, 2021 · 13 comments
Assignees
Labels
enhancement New feature or request

Comments

@Raagaception
Copy link

Is this even possible? I started using the Imgur plugin extensively, but I also use Obsidian_to_Anki. I recently discovered that in conversion to Anki, the Imgur links are directly loaded into the cards - which means most of the images in the deck can't be loaded without an active internet connection. I wasn't even aware of this until I made the deck public and users told me about it, which is a huge blunder on my part.

There is a workaround involving exporting and scripting the deck within Anki itself, but on regenerating the cards with Obsidian it would just replace it with links again. Only way to fix this now is with some method of replacing 300+ links in my vault with local images, only in selective .md files. Any solution or workaround for this issue would be appreciated!

@gavvvr gavvvr added the enhancement New feature or request label May 20, 2021
@gavvvr
Copy link
Owner

gavvvr commented May 20, 2021

Hi @Raagaception. There is no automated solution to your problem yet, but I think it is totally possible. Your request is an enhanced duplicate of #7 since you want to easily switch images source both ways.

I do not have a priority to implement this right now, but I would do it when I have a free time. Also contributions are welcomed.

@Raagaception
Copy link
Author

I saw that other issue too. Since this is encompasses that issue and more, should I close this issue or should the other issue be closed?

@gavvvr
Copy link
Owner

gavvvr commented May 20, 2021

Let's leave them both open since they are not equivalent. They are linked and that's is enough for now.
This one includes more and I think I would not implement it in one take (I would have started with a smaller one and then move to the larger one)

@Raagaception
Copy link
Author

And on an unrelated note, I was able to fix my issue. I extracted all links from my vault, put it in a .txt file, then used this Chrome extension to mass download all images. Then just searched and replaced ![](https://i.imgur.com/ with ![[, and .png) with .png]], et Voila!

I can also do the exact reverse in search and replace, and it will give back the original Imgur link. Short term workaround for anyone who needs a weird fix till the next feature update. Thanks for your quick support @gavvvr !

@gavvvr gavvvr self-assigned this Sep 9, 2021
@ih8snow
Copy link

ih8snow commented Mar 19, 2022

Hi Kirill,
I really would love to have this feature implemented (and the other related issue). So in case you have the time, what kind of funding (i.e. via Kofi) would help you in order to implement these features?

@gavvvr
Copy link
Owner

gavvvr commented Mar 19, 2022

Hi @ih8snow

So in case you have the time, what kind of funding ...

Yeah, the biggest problem is the lack of time, especially right now. There is no such thing as "donations goal" set for implementing new features. kofi link was left just in case someone wants to say "thank you" with money :) I will implement new features anyway as soon as I can afford myself to spend time on it. Unfortunately I do not feel like I will have a spare time in the nearest month.

One month ago I was focusing on issue number 23 (commands for images resizing) and almost have finished implementing it, but haven't polished the solution and after that I had no time at all so there is still no new releases.


This particular feature request can be seen as a request of 2 separate features:

  1. download remote images
  2. upload local ones
    I would really like to implement the (2)nd one, because this would help a lot to free up space for new users with existing vaults. For now I do not know how to traverse all the notes, collect all the images and upload them in batches, also replacing local links with remote ones and removing local images. I only know how to upload an existing single image with right-click on it (see POC branch in case someone can and wants to continue the work on batch upload)

Regarding the download (1) of remote images and replacing them with local links: now I do not think that it should be a feature of an Imgur plugin, because it's better to have a separate generic plugin to convert ANY remote images to local ones. I did a quick search right now to check if someone has implemented this and looks like there is already such a plugin: https://github.com/aleksey-rezvov/obsidian-local-images. @Raagaception, @ih8snow please check it out and let me know if it fulfills your needs in terms of remote->local images conversion.

@ih8snow
Copy link

ih8snow commented Mar 20, 2022

Hi @gavvvr
fully understand.
The mentioned plugin works for me - DL all external images.

It would be great to have a solution for uploading local images.
I.e. When I "import" word documents the images are stored in an atatachment folder and are linked in the converted md file.
So I see them in Obsidian, but they are local...so my final step would be to upload them to imgur.

I very often have files to import and Obsidian really is missing something here, so part of that workaround is your add-on.

Thanks again for the great plugin.

@Hugo-Persson
Copy link

Hi @ih8snow

So in case you have the time, what kind of funding ...

Yeah, the biggest problem is the lack of time, especially right now. There is no such thing as "donations goal" set for implementing new features. kofi link was left just in case someone wants to say "thank you" with money :) I will implement new features anyway as soon as I can afford myself to spend time on it. Unfortunately I do not feel like I will have a spare time in the nearest month.

One month ago I was focusing on issue number 23 (commands for images resizing) and almost have finished implementing it, but haven't polished the solution and after that I had no time at all so there is still no new releases.

This particular feature request can be seen as a request of 2 separate features:

  1. download remote images
  2. upload local ones
    I would really like to implement the (2)nd one, because this would help a lot to free up space for new users with existing vaults. For now I do not know how to traverse all the notes, collect all the images and upload them in batches, also replacing local links with remote ones and removing local images. I only know how to upload an existing single image with right-click on it (see POC branch in case someone can and wants to continue the work on batch upload)

Regarding the download (1) of remote images and replacing them with local links: now I do not think that it should be a feature of an Imgur plugin, because it's better to have a separate generic plugin to convert ANY remote images to local ones. I did a quick search right now to check if someone has implemented this and looks like there is already such a plugin: https://github.com/aleksey-rezvov/obsidian-local-images. @Raagaception, @ih8snow please check it out and let me know if it fulfills your needs in terms of remote->local images conversion.

@gavvvr Have any work been started on uploading all local images to Imgur? I would gladly help develop the feature if you don't have any sparetime right now.

@gavvvr
Copy link
Owner

gavvvr commented Apr 19, 2023

Hi @Hugo-Persson

there is only a single commit to upload an existing single local image with right-click and "trash" the local copy

Actually, I hope I will have a time soon to start the work on that. Yes, it would be very helpful if you contribute somehow, i.e. by finding an elegant way to iterate over all images within the note, and iterate over notes over the vault, and have a method for precise image replacement (while the content of a single note may change, which means the coordinates of local images my change, because of many different callbacks caused by concurrent images uploads) 🙏.
I did not check an obsidian API for quite a long time, maybe something already exists for iteration. You can start working on a simple case on migrating all local images within a single note pretending there are no network issues (happy path) and after achieving this goal, I would think about careful errors handling to avoid any images loss and a mess on failed batch uploads

@Hugo-Persson
Copy link

Alright, I am going to look into it and create a PR.

Thank you for this amazing extension @gavvvr, I am really enjoying it 👍

@06000208
Copy link

This is important, as imgur intends to start purging old anonymous uploads

@gavvvr
Copy link
Owner

gavvvr commented Apr 21, 2023

@06000208 thanks for letting me know. Here is the source:

We will be focused on removing old, unused, and inactive content that is not tied to a user account

Sounds dangerous, but I guess if you open your notes in preview mode (which will lead to image load), your image is again not a subject for removal for a significant period of time.

Btw I think converting "any" remote image into local one deserves a separate plugin, not tied to imgur. Such plugin can covert images by url pattern to convert only those uploaded to imgur
UPD: such plugins already exist:
https://github.com/aleksey-rezvov/obsidian-local-images
https://github.com/Sergei-Korneev/obsidian-local-images-plus

@imshenwei
Copy link

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

No branches or pull requests

6 participants