Settings
Settings related to the package were included in a dict named DJANGO_GALLERY_FIELD_CONFIG.
DJANGO_GALLERY_FIELD_CONFIG
Default:
{
"bootstrap_version": 3,
"assets": {
"jquery": "path/or/url/to/jquery.js",
"bootstrap_css": "path/or/url/to/bootstrap.css",
"bootstrap_js": "path/or/url/to/bootstrap.js",
"extra_js": [],
"extra_css": [],
},
"thumbnails": {
"size": "120x120",
"quality": 80
},
"jquery_file_upload_ui_options": {
"autoUpload": False,
"imageMaxWidth": 1024,
"imageMaxHeight": 1024,
...
},
"jquery_file_upload_ui_sortable_options": {
"disabled": False,
"delay": 300,
"animation": 200,
...
}
"prompt_alert_if_changed_on_window_reload": True,
"widget_hidden_input_css_class": "django-galleryfield",
}
See details below.
bootstrap_version
Default: 3
The value denotes the version of Twitter Bootstrap used by GalleryWidget. Allow values include 3, 4 or 5.
assets
The assets needed for rendering GalleryWidget.
jquery: The path or url to jQuery.js. Defaults tohttps://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js.bootstrap_css: The path or url to bootstrap.css, or a dict with bootstrap_version s as key, and path/url as value. Defaults to:
{
3: "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css",
4: "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.1/css/bootstrap.min.css",
5: "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css",
}
bootstrap_js: The path or url to bootstrap.js, or a dict with bootstrap_version s as key, and path/url as value. Defaults to:
{
3: "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.js",
4: "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.6.1/css/bootstrap.min.js",
5: "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.js",
}
extra_jsandextra_cssallow user to add customized static files when customize the rendering of the widget. Both defaults to [].
If you want to serve assets files locally, you can override those values using the relative path
of those files in STATICFILES_DIRS .
thumbnails
Default:
"thumbnails": {
"size": "120x120",
"quality": 80
},
We use sorl.thumbnail to generate the thumbnails
in the project. The term size correspond to
geometry in sorl.thumbnail.
Currently, we accept the following format of size:
'120x80'
(120, 80) # same as '120x80'
('120', '80') # same as '120x80'
[120, 80] # same as '120x80'
['120', '80'] # same as '120x80'
120 # same as '120x120'
The size can be overridden when initializing galleryfield.widgets.GalleryWidget via
thumbnail_size.
For quality, please refer to quality option in sorl.thumbnail.
jquery_file_upload_ui_options
The default value is listed in galleryfield.defaults.JQUERY_FILE_UPLOAD_UI_DEFAULT_OPTIONS.
- galleryfield.defaults.JQUERY_FILE_UPLOAD_UI_DEFAULT_OPTIONS
dict: The default options for jQuery-File-Upload module in jQuery file upload UI. The values can be overridden when initializing
galleryfield.widgets.GalleryWidgetviajquery_file_upload_ui_options. Please refer to available options for the details and more options.
JQUERY_FILE_UPLOAD_UI_DEFAULT_OPTIONS = {
"autoUpload": False,
"imageMaxWidth": 1024,
"imageMaxHeight": 1024,
"loadImageFileTypes": r"/^image\/(gif|jpeg|png|bmp|webp|svg\+xml|x-icon)$/",
"sequentialUploads": True,
"acceptFileTypes": r"/(\.|\/)(png|gif|bmp|jpe?g|tif|ico|webp)$/i",
"imageOrientation": True,
"maxFileSize": 1.5 * 1024 ** 2, # 1.5Mb
"minFileSize": 0.0001 * 1024 ** 2, # 0.0001Mb
"disableImageResize": "/Android(?!.*Chrome)|Opera/.test(window.navigator "
"&& navigator.userAgent)",
}
Warning
Options previewMaxWidth and previewMaxHeight were ignored in favor of
thumbnail settings.
Option maxNumberOfFiles will be ignored and should be configured in the formfield.
See example in galleryfield.fields.GalleryFormField.
Options fileInput, paramName and singleFileUploads were also
ignored (overridden).
jquery_file_upload_ui_sortable_options
The default value is listed in galleryfield.defaults.JQUERY_FILE_UPLOAD_UI_DEFAULT_SORTABLE_OPTIONS.
- galleryfield.defaults.JQUERY_FILE_UPLOAD_UI_DEFAULT_SORTABLE_OPTIONS
dict: The default options for SortableJS used in jQuery file upload UI. See available options for details. Notice that, callback options currently can not be configured here.
JQUERY_FILE_UPLOAD_UI_DEFAULT_SORTABLE_OPTIONS = {
"disabled": False,
"delay": 300,
"animation": 200,
"touchStartThreshold": 5,
"ghostClass": "galleryWidget-sortable-ghost",
"chosenClass": "galleryWidget-sortable-chosen",
"filter": ".btn, .toggle, img, a, span, progress",
}
prompt_alert_if_changed_on_window_reload
Default: True
Whether prompt an alert when navigating away or closing the tablet/browser if there were changes
on GalleryField in the page.