Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This partly closes #55.
What it does
This adds support to render images as base64 data instead of a URL in the XML file. It implements a
--images-base64
command-line toggle defaulting toFalse
. This would produce code like<img src="data:image/jpeg;base64,/9j/<base64 data>"/>
instead of<img src="%24IMS-CC-FILEBASE%24/images/trex.jpeg"/>
.Lack of base64 image support in LMSes
After thorough evaluation, it does not appear that either Canvas LMS or D2L's BrightSpace, which is my prime target platform, support base64 images well. In more details:
Potential uses
As is it, I fail to see practical value for my own use case and for Canvas LMS users in this very pull request. However, it may be used in another LMS platform with better support for base64 images. It may also be used as a base for improvements or further investigation by interested parties.
To do
The mime-type is hard-coded to
jpeg
in this PR, as I did not see real interest in going further for the aforementioned reasons. To make it usable, one would need to detect the images' mime-types, using the filetype Python package for instance.One could also use PIL to convert image files to base64 directly, and then be able to properly handle resizing at the image data level (not the CSS level) and other neat features, but that would add quite a large dependency.