Settings
Settings related to the package were included in a dict named DJANGO_GALLERY_FIELD_CONFIG
.
DJANGO_GALLERY_FIELD_CONFIG
Default:
{
"assets": {
"jquery.js": "jquery/dist/jquery.min.js",
"jquery-ui.js": "jquery-ui-dist/jquery-ui.min.js",
...
"extra_js": [],
"extra_css": [],
},
"thumbnails": {
"size": "120x120",
"quality": 80
},
"widget_hidden_input_css_class": "django-galleryfield",
"prompt_alert_if_changed_on_window_reload": True,
"jquery_file_upload_ui_options": {
"autoUpload": False,
"imageMaxWidth": 1024,
"imageMaxHeight": 1024,
...
}
}
See details below.
assets
Default:
{
"extra_js": [],
"extra_css": []
}
extra_js
and extra_css
allow user to add customized static files when customize
the rendering of the widget.
JQUERY_FILE_UPLOAD_UI_DEFAULT_OPTIONS = {
"autoUpload": False,
"imageMaxWidth": 1024,
"imageMaxHeight": 1024,
"loadImageFileTypes": r"/^image\/(gif|jpeg|png|bmp|svg\+xml)$/",
"sequentialUploads": "true",
"acceptFileTypes": r"/(\.|\/)(png|gif|bmp|jpe?g)$/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)",
}
"""dict: The default options for jQuery-File-Upload module.
"""
# {{{ DO NOT change this if you have deployed this app on you production server!
# Or else it might cause unexpected result!
DEFAULT_UPLOAD_URL_NAME = "galleryfield-builtingalleryimage-upload"
DEFAULT_CROP_URL_NAME = "galleryfield-builtingalleryimage-crop"
DEFAULT_FETCH_URL_NAME = "galleryfield-builtingalleryimage-fetch"
DEFAULT_TARGET_IMAGE_MODEL = "galleryfield.BuiltInGalleryImage"
DEFAULT_TARGET_IMAGE_FIELD_NAME = "image"
DEFAULT_CREATOR_FIELD_NAME = "creator"
# }}}
BUILT_IN_JS = ["js/galleryfield-ui.js"]
BUILT_IN_CSS = []
EXTRA_JS = []
EXTRA_CSS = []
DEFAULT_THUMBNAIL_SIZE = "120x120"
DEFAULT_THUMBNAIL_QUALITY = 80
WIDGET_HIDDEN_INPUT_CSS_CLASS = "django-galleryfield"
PROMPT_ALERT_ON_WINDOW_RELOAD_IF_CHANGED = True
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.
JQUERY_FILE_UPLOAD_UI_DEFAULT_OPTIONS = {
"autoUpload": False,
"imageMaxWidth": 1024,
"imageMaxHeight": 1024,
"loadImageFileTypes": r"/^image\/(gif|jpeg|png|bmp|svg\+xml)$/",
"sequentialUploads": "true",
"acceptFileTypes": r"/(\.|\/)(png|gif|bmp|jpe?g)$/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)",
}
The value can be overridden when initializing galleryfield.widgets.GalleryWidget
via
jquery_file_upload_ui_options
.
Please refer to available options
for the details and more options.
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).