jdan / cleaver

30-second slideshows for hackers
http://jdan.github.io/cleaver
MIT License
4.03k stars 305 forks source link

Include local images with base64 encoded data uri #93

Closed GMouron closed 8 years ago

GMouron commented 10 years ago

In order to make the generated presentation even more self-contained, this PR allows the user to specify an option to encode images present locally in base64 format and inserted as data uris in the presentation instead of a normal src reference which forces to always have the images next to the html presentation.

This works, for the moment, only for images that are on the machine where cleaver is run, and specified with a relative path.

jdan commented 10 years ago

I love this, nice work.

I'm thinking, to make things simpler, we should base64 encode every image (even those in CSS) regardless if they're local or on the web. Then we can just have a single base64: true option.

What do you think? I'd be happy to merge this onto a branch and keep hacking.

GMouron commented 10 years ago

Hey thanks. Yeah that was my ultimate goal, I see 3 problems though, that's why I did not tackle them right away :

  1. the CSS is not parsed, therefore, it's a bit more difficult to get the image url (I guess a good regex can work here)
  2. the images that are not local : the main problem is that the renderer for the marked library doesn't work with callbacks or promises, therefore, you can't have async I/O or Http requests. That's why I went with sync I/O here.
  3. there are potential cache issues that need to be arranged (I guess we can make something simple regarding that here though)

I think the main problem here is number 2. There are some possible solutions

So those are all my thoughts and why I first went only with local images :)

geiseri commented 8 years ago

This has been here for a while. I would love this feature, are there plans to merge it? Even without it being perfect.

drawveloper commented 8 years ago

Closing this PR for now. If you want to rebase from master and re-open, that would be lovely!