I do it like this:
img.src = "1234 ... 56789" + //
"01234567 ... 7890" + //
.....
"67879878907890";
Some people I work with like to put the +
on the front of the line, claiming its easier to read.
Assume you have the image data, base64 encoded in a string. A sort of pseudo C/Java/Javascript like language would have code something like this (since I don't know Python):
String image64 = ...
String output = "img.src = \"data:image/jpg;base64, ";
for (int i = 0; i < image64.length ; i += 100) {
if (i > 0) {
output += "\" + // \n \"";
}
if (i + 100 < image64.length) {
output += image64.substring(i, i+100);
} else {
output += image64.substring(i); // this gets the rest
}
}
output += "\";\n";
Then you write the value of output
to where ever you are putting your javascript.
Now a quick look a Django and Python stuff leads me to suspect it would look something like this in the template:
img.src = "data:image/jpg;base64, " + //
{% for line in photo_data_lines %}
"{{ line }}" + //
{% endfor %}
"";
But you'd have to set up the photo_data_lines
array with 100 character chunks of the image data in each element beforehand. (Or however long you want the chunks.)