Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-random-image-from-folder, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size django_random_image_from_folder-0.0.3-py3-none-any.whl (3.8 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size django-random-image-from-folder-0.0.3.tar.gz (2.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page