Skip to content

Commit

Permalink
use ThumbnailOptions instead of a dict (#1340)
Browse files Browse the repository at this point in the history
* use ThumbnailOptions instead of a dict

* disable isort in pre-commit.ci
  • Loading branch information
jrief committed May 9, 2023
1 parent 7c22e16 commit ea1b694
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
on:
pull_request:
push:
branches: [master]

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/action@v3.0.0
- uses: pre-commit-ci/lite-action@v1.0.1
if: always()
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ repos:
- id: check-merge-conflict
- id: mixed-line-ending

- repo: https://github.com/pycqa/isort
rev: 5.11.4
hooks:
- id: isort
# - repo: https://github.com/pycqa/isort
# rev: 5.11.4
# hooks:
# - id: isort
8 changes: 5 additions & 3 deletions filer/templatetags/filer_admin_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.utils.translation import gettext_lazy as _

from easy_thumbnails.files import get_thumbnailer
from easy_thumbnails.options import ThumbnailOptions

from filer import settings
from filer.admin.tools import admin_url_params, admin_url_params_encoded
Expand Down Expand Up @@ -116,11 +117,12 @@ def file_icon_context(file, detail, width, height):
opts = {'size': (width, height), 'upscale': True}
else:
opts = {'size': (width, height), 'crop': True}
icon_url = thumbnailer.get_thumbnail(opts).url
thumbnail_options = ThumbnailOptions(opts)
icon_url = thumbnailer.get_thumbnail(thumbnail_options).url
context['alt_text'] = file.default_alt_text
if mime_subtype != 'svg+xml':
opts['size'] = 2 * width, 2 * height
context['highres_url'] = thumbnailer.get_thumbnail(opts).url
thumbnail_options['size'] = 2 * width, 2 * height
context['highres_url'] = thumbnailer.get_thumbnail(thumbnail_options).url
elif mime_maintype in ['audio', 'font', 'video']:
icon_url = staticfiles_storage.url('filer/icons/file-{}.svg'.format(mime_maintype))
elif mime_maintype == 'application' and mime_subtype in ['zip', 'pdf']:
Expand Down

0 comments on commit ea1b694

Please sign in to comment.