Snippet List
Read the image url as base64 in django, this snippet usefull if you using the `django-easy-pdf` to solve this issue https://github.com/nigma/django-easy-pdf/issues/53
Usage example:
```
<img src="{{ profile.photo.url|read_image_as_base64 }}">
```
- django
- image
- templatetags
- base64
- imagepreview
A custom templatetag for inlining image in the browser.
The principe is to base64 encode the image and avoid a http request.
There is a cache handling, you just have to specify a writable directory.
An example of the utilisation (template part): [http://djangosnippets.org/snippets/2267/](http://djangosnippets.org/snippets/2267/)
The explication on [http://raphaelbeck.wordpress.com/2010/11/14/make-inline-images-to-improve-performance-with-django-template-tags/](http://raphaelbeck.wordpress.com/2010/11/14/make-inline-images-to-improve-performance-with-django-template-tags/)
- tag
- image
- templatetag
- base64
This Base64Field class can be used as an alternative to a BlobField, which is not supported by Django out of the box.
The base64 encoded data can be accessed by appending _base64 to the field name. This is especially handy when using this field for sending eMails with attachment which need to be base64 encoded anyways.
**Example use:**
class Foo(models.Model):
data = Base64Field()
foo = Foo()
foo.data = 'Hello world!'
print foo.data # will 'Hello world!'
print foo.data_base64 # will print 'SGVsbG8gd29ybGQh\n'
- django
- model
- field
- base64
- blob
- base64field
7 snippets posted so far.