|
2 | 2 | import os |
3 | 3 |
|
4 | 4 | from django.conf import settings |
5 | | -from django.core.exceptions import ImproperlyConfigured |
6 | 5 | from django.utils.module_loading import import_string as get_storage_class |
7 | 6 | from django.utils.translation import gettext_lazy as _ |
8 | 7 |
|
|
38 | 37 |
|
39 | 38 | FILER_PAGINATE_BY = getattr(settings, 'FILER_PAGINATE_BY', 100) |
40 | 39 |
|
| 40 | +if hasattr(settings, "FILER_ADMIN_ICON_SIZES"): |
| 41 | + logger.warning("FILER_ADMIN_ICON_SIZES is deprecated and will be removed in the future.") |
| 42 | + |
41 | 43 | _ICON_SIZES = getattr(settings, 'FILER_ADMIN_ICON_SIZES', ('16', '32', '48', '64')) |
42 | | -if not _ICON_SIZES: |
43 | | - raise ImproperlyConfigured('Please, configure FILER_ADMIN_ICON_SIZES') |
44 | 44 | # Reliably sort by integer value, but keep icon size as string. |
45 | 45 | # (There is some code in the wild that depends on this being strings.) |
46 | 46 | FILER_ADMIN_ICON_SIZES = [str(i) for i in sorted([int(s) for s in _ICON_SIZES])] |
47 | 47 |
|
48 | | -# Filer admin templates have specific icon sizes hardcoded: 32 and 48. |
49 | | -_ESSENTIAL_ICON_SIZES = ('32', '48') |
50 | | -if not all(x in FILER_ADMIN_ICON_SIZES for x in _ESSENTIAL_ICON_SIZES): |
51 | | - logger.warn( |
52 | | - "FILER_ADMIN_ICON_SIZES has not all of the essential icon sizes " |
53 | | - "listed: {}. Some icons might be missing in admin templates.".format( |
54 | | - _ESSENTIAL_ICON_SIZES)) |
| 48 | +# Currently, these two icon sizes are hard-coded into the admin and admin templates |
| 49 | +FILER_TABLE_ICON_SIZE = getattr(settings, "FILER_TABLE_ICON_SIZE", 40) |
| 50 | +FILER_THUMBNAIL_ICON_SIZE = getattr(settings, "FILER_THUMBNAIL_ICON_SIZE", 120) |
| 51 | +DEFERRED_THUMBNAIL_SIZES = ( |
| 52 | + FILER_TABLE_ICON_SIZE, |
| 53 | + 2 * FILER_TABLE_ICON_SIZE, |
| 54 | + FILER_THUMBNAIL_ICON_SIZE, |
| 55 | + 2 * FILER_THUMBNAIL_ICON_SIZE, |
| 56 | +) |
| 57 | + |
55 | 58 |
|
56 | 59 | # This is an ordered iterable that describes a list of |
57 | 60 | # classes that I should check for when adding files |
@@ -283,7 +286,6 @@ def update_server_settings(settings, defaults, s, t): |
283 | 286 | }, |
284 | 287 | } |
285 | 288 |
|
286 | | -DEFERRED_THUMBNAIL_SIZES = (40, 80, 160) |
287 | 289 | IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.gif', '.webp'] |
288 | 290 | IMAGE_MIME_TYPES = ['gif', 'jpeg', 'png', 'x-png', 'svg+xml', 'webp'] |
289 | 291 |
|
@@ -322,3 +324,7 @@ def update_server_settings(settings, defaults, s, t): |
322 | 324 | except (ModuleNotFoundError, ImportError): |
323 | 325 | # Import error? No django CMS used: stay with own icons |
324 | 326 | pass |
| 327 | + |
| 328 | + |
| 329 | +# SVG are their own thumbnails if their size is below this limit |
| 330 | +FILER_MAX_SVG_THUMBNAIL_SIZE = getattr(settings, "FILER_MAX_SVG_THUMBNAIL_SIZE", 1024 * 1024) # 1MB default |
0 commit comments