Search code examples
cloudmarkdownstorageembedportability

Are there any simple solutions to achieve permanence when adding photos and videos from the web to Markdown files?


I love using markdown to save images and videos from around the web, but hate the idea that they could be lost if a web address changes or goes down.

However, saving photos and videos to my hard drive slows down the note taking process and creates issues with portability, especially if markdown files are in the cloud (since the file path is needed).

There are ways to directly embed photos but that seems messy and won't work the same for videos.


Solution

  • You have to understand that videos and images have a fileSize, and for video it can quickly jump over 200Mb.

    Your readers will not be happy if they have to wait 1 minute to get the privilege to read your .md

    For image, what you call "messy" is the base64 representation of the image ? It is not that bad but won't necessarily work as you can see on this repo

    I think it works on wikipedia and github pages though.

    Below the script to obtain the base64 representation of your image in your clipboard:

    cat $1 | base64 | xargs echo -n | xclip -selection clipboard
    

    As for videos you can put the clickbait image from the youtube video and open the link like in this example

    <a href="https://www.youtube.com/watch?v=QchosaSvyY4
    " target="_blank"><img src="http://img.youtube.com/vi/QchosaSvyY4/0.jpg"
    alt="Chrono Trigger Best Ending on youtube" width="240" height="180" border="10" /></a>
    

    So if you have space issues you can upload on youtube and then use the above trick.