BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.28k stars 1.9k forks source link

HTML image export #799

Closed gnsiva closed 6 years ago

gnsiva commented 6 years ago

For Bug Reports

This is using solidnerd/docker-bookstack

Expected Behavior

HTML export would contain images. These images are copy and pasted into the document, and so are uploaded into the bookstack uploads directory. This works correctly in normal use (expect for export).

Current Behavior

No images are visible in HTML export. When I inspect the html, I can see that it is a relative link which doesn't make sense for an export. e.g.

<img src="/uploads/images/gallery/2018-04-Apr/scaled-840-0/image-1523372744778.png" alt="">

and
<img src="/uploads/images/gallery/2018-04-Apr/scaled-840-0/image-1523372680404.png" alt="">

I guess there should be a way of configuring the server address so that this is filled in before /uploads? Also it would be nice if base64 encoding and embedding the images was also supported.

Steps to Reproduce

Launch solidnerd version of bookstack docker container, paste an image into a bookstack page and try to html export.

mendiromania commented 6 years ago

well it's called export to html after all but you could base64 the img bytes and add it to the img src attribute as "data:image/" . $fileExt . ";base64," . $base64data http://php.net/manual/en/function.base64-encode.php

ssddanbrown commented 6 years ago

Hi @gnsiva and @mendiromania,

Currently BookStack does attempt to Base64 embed images on the page for exports as shown here: https://github.com/BookStackApp/BookStack/blob/master/app/Services/ExportService.php#L182

If the image is not found then it's not base64 included.

@gnsiva, Just some questions to help debugging this issue:

gnsiva commented 6 years ago

@ssddanbrown To quickly answer, I am using the full docker-compose. And regarding environment variables, I'm not setting anything other than what is set in the solidnerd setup.

gnsiva commented 6 years ago

@ssddanbrown Sorry, my bad, setting the APP_URL environment variable in the docker-compose file fixed the exporting. It is base64 encoding it too, hurrah! I will put in an issue to the solidnerd repo that setting the APP_URL should be in the instructions somewhere

ssddanbrown commented 6 years ago

@gnsiva Ah, Fantastic, Happy to hear things are working now. Will close this issue.

gnsiva commented 6 years ago

Thanks for your help!