Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to try using all items as large images. #562

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions girder/girder_large_image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ def checkForLargeImageFiles(event):
exts = [ext.split()[0] for ext in file.get('exts') if ext]
if set(exts[-2:]).intersection(girder_tilesource.KnownExtensions):
possible = True
if not file.get('itemId') or not possible:
if not file.get('itemId'):
return
if not Setting().get(constants.PluginSettings.LARGE_IMAGE_AUTO_SET):
autoset = Setting().get(constants.PluginSettings.LARGE_IMAGE_AUTO_SET)
if not autoset or (not possible and autoset != 'all'):
return
item = Item().load(file['itemId'], force=True, exc=False)
if not item or item.get('largeImage'):
Expand Down Expand Up @@ -211,7 +212,6 @@ def handleRemoveFile(event):
@setting_utilities.validator({
constants.PluginSettings.LARGE_IMAGE_SHOW_THUMBNAILS,
constants.PluginSettings.LARGE_IMAGE_SHOW_VIEWER,
constants.PluginSettings.LARGE_IMAGE_AUTO_SET,
})
def validateBoolean(doc):
val = doc['value']
Expand All @@ -220,6 +220,16 @@ def validateBoolean(doc):
doc['value'] = (str(val).lower() != 'false')


@setting_utilities.validator({
constants.PluginSettings.LARGE_IMAGE_AUTO_SET,
})
def validateBooleanOrAll(doc):
val = doc['value']
if str(val).lower() not in ('false', 'true', 'all', ''):
raise ValidationException('%s must be a boolean or "all".' % doc['key'], 'value')
doc['value'] = val if val in {'all'} else (str(val).lower() != 'false')


@setting_utilities.validator({
constants.PluginSettings.LARGE_IMAGE_SHOW_EXTRA_PUBLIC,
constants.PluginSettings.LARGE_IMAGE_SHOW_EXTRA,
Expand Down
1 change: 1 addition & 0 deletions girder/girder_large_image/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ class PluginSettings:
LARGE_IMAGE_AUTO_SET = 'large_image.auto_set'
LARGE_IMAGE_MAX_THUMBNAIL_FILES = 'large_image.max_thumbnail_files'
LARGE_IMAGE_MAX_SMALL_IMAGE_SIZE = 'large_image.max_small_image_size'
LARGE_IMAGE_AUTO_USE_ALL_FILES = 'large_image.auto_use_all_files'
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ form#g-large-image-form(role="form")
| Uploaded and imported items with files that have MIME-types or extensions that are typical of large images will be set as large image items if they can be used without running a conversion job.
.g-large-image-auto-set-container
label.radio-inline
input.g-large-image-auto-set-on(type="radio", name="g-large-image-auto-set", checked=settings['large_image.auto_set'] !== false ? 'checked': undefined)
input.g-large-image-auto-set-on(type="radio", name="g-large-image-auto-set", checked=settings['large_image.auto_set'] === true ? 'checked' : undefined)
| Automatically use large images
label.radio-inline
input.g-large-image-auto-set-off(type="radio", name="g-large-image-auto-set", checked=settings['large_image.auto_set'] !== false ? undefined : 'checked')
input.g-large-image-auto-set-off(type="radio", name="g-large-image-auto-set", checked=settings['large_image.auto_set'] === false ? 'checked' : undefined)
| No automatic use
label.radio-inline
input.g-large-image-auto-set-all(type="radio", name="g-large-image-auto-set", checked=settings['large_image.auto_set'] === 'all' ? 'checked' : undefined)
| Automatically try to use all files as large images
.form-group
label
| Maximum size of regular images to use without conversion
Expand Down
2 changes: 1 addition & 1 deletion girder/girder_large_image/web_client/views/configView.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var ConfigView = View.extend({
value: this.$('.g-large-image-default-viewer').val()
}, {
key: 'large_image.auto_set',
value: this.$('.g-large-image-auto-set-on').prop('checked')
value: this.$('.g-large-image-auto-set-all').prop('checked') ? 'all' : this.$('.g-large-image-auto-set-on').prop('checked')
}, {
key: 'large_image.max_thumbnail_files',
value: +this.$('.g-large-image-max-thumbnail-files').val()
Expand Down