Django Random Image From Folder is a simple app to load a random image from a specified directory.
Project description
Django Random Image From Folder
Django Random Image From Folder is a simple app to load a random image from a specified directory.
It's trivially simple but I've needed it a few times so I thought maybe others have too.
Installation
Add 'random_image' to INSTALLED_APPS.
Settings
All settings are optional
RANDOM_IMAGE_DIR
Default: Not defined
A path to the directory from which to load the random images. Relative to MEDIA_ROOT.
Note: Passing a path to the template tag will always override the RANDOM_IMAGE_DIR setting.
RANDOM_IMAGE_EXTENSIONS
Default: ['.jpg','.jpeg','.png','.gif']
A list containing extensions to be considered when choosing a random image.
Usage
Pass in a path to the image directory::
{% load random_image %}
<img src="{{ MEDIA_URL}}{% random_image "path/to/image/dir" %}">
The path to the image directory should be relative to MEDIA_ROOT.
or if you have added RANDOM_IMAGE_DIR to your settings file::
{% load random_image %}
That's it! Simple as it gets.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-random-image-from-folder-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 232355a4b6b8641a3f0b0f5775abff1760a46bcf05e68b5770422872e420e58b |
|
MD5 | efe27b804dbe63aa129bdf8aa22454c2 |
|
BLAKE2b-256 | 08dbe3a20e7422a1a9767dacf29c1d91b8f52a1377b0bd71e6455cb88eb50bf2 |
Hashes for django_random_image_from_folder-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ac0849bfa5a356a5a7bb61ec4bba613e6d9d286f15f2053ca428275d783cb81 |
|
MD5 | 906d7968b78cb71c5b314a3d84b2fc68 |
|
BLAKE2b-256 | aac7016ff652b8811e69daab1d625aff7e3654edec732a7f88c6952b4496e62e |