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

thumbnail is missing... [BUG] #1412

Closed
1 of 2 tasks
prepstarr opened this issue Aug 18, 2023 · 25 comments
Closed
1 of 2 tasks

thumbnail is missing... [BUG] #1412

prepstarr opened this issue Aug 18, 2023 · 25 comments

Comments

@prepstarr
Copy link

prepstarr commented Aug 18, 2023

Description

thumbnail image in the preview section is missing ...

image

Steps to reproduce

Expected behaviour

thumbnail should show image

show image

Actual behaviour

broken link

FILER_STORAGES = {
    'public': {
            'OPTIONS': {
                'location': '/home/sixpiece/python/emploiquebec/media/filer',
                'base_url': '/media/filer/',
            },
            'UPLOAD_TO': 'filer.utils.generate_filename.randomized',
            'UPLOAD_TO_PREFIX': 'filer_public',
        },
        'thumbnails': {
                'location': '/home/sixpiece/python/emploiquebec/media/filer_thumbnails',
                'base_url': '/media/filer_thumbnails/',
            },
        },
    },
    'private': {
        'main': {
            'ENGINE': 'filer.storage.PrivateFileSystemStorage',
            'OPTIONS': {
                'location': '/usr/home/sixpiece/python/emploiquebec/smedia/filer',
                'base_url': '/smedia/filer/',
            },
            'UPLOAD_TO': 'filer.utils.generate_filename.randomized',
            'UPLOAD_TO_PREFIX': 'filer_public',
        },
        'thumbnails': {
            'ENGINE': 'filer.storage.PrivateFileSystemStorage',
            'OPTIONS': {
                'location': '/usr/home/sixpiece/python/emploiquebec/smedia/filer_thumbnails',
                'base_url': '/smedia/filer_thumbnails/',
            },
        },
    },
} 
```in settings.py

this directory exists : ```
/home/sixpiece/python/emploiquebec/media/filer_thumbnails/filer_public_thumbnails/filer_public/fb/5b/fb5bdd6d-9a78-4a7c-ab42-39c41d3b510b this directory exists and the following files exist: sheldon-lub.png__160x160_q85_crop_subsampling-2.jpg
sheldon-lub.png__180x180_q85_crop_subsampling-2_upscale.jpg
sheldon-lub.png__40x40_q85_crop_subsampling-2.jpg
sheldon-lub.png__70x70_q85_crop_subsampling-2.jpg
sheldon-lub.png__70x70_q85_subsampling-2.jpg
sheldon-lub.png__80x80_q85_crop_subsampling-2.jpg

it looks like it's close but for some reason thumbnail is not generated...

Screenshots

Additional information (CMS/Python/Django versions)

Do you want to help fix this issue?

  • Yes, I want to help fix this issue and I will join #workgroup-pr-review on Slack to confirm with the community that a PR is welcome.
  • No, I only want to report the issue.
@fsbraun
Copy link
Member

fsbraun commented Aug 18, 2023

Can you share your MEDIA settings?

@prepstarr
Copy link
Author

Yes my apologies for the late return if this is not the right answer, I will be back at it on Saturday night... I was up late that night and did an hour sieste now but I want to finish making my soup , etc..

adding MEDIA root

MEDIA_ROOT = '/usr/home/sixpiece/python/emploiquebec/media'

MEDIA_URL = '/media/'e__).resolve().parent.parent

@fsbraun
Copy link
Member

fsbraun commented Aug 19, 2023

The MEDIA_URL line seems garbeled ... at least by the balance of opening and closing brackets?

@prepstarr
Copy link
Author

prepstarr commented Aug 20, 2023

sorry about that there was probably something wrong with how it posted...

adding MEDIA root

MEDIA_ROOT = '/usr/home/sixpiece/python/emploiquebec/media'

MEDIA_URL = '/media/'

I just looked at it now and was wondering how I came up with such a thing...

going to share the whole settings.py ...

@prepstarr
Copy link
Author

from pathlib import Path

import os.path

USE_TZ = False

FILER_CANONICAL_URL = 'canonical/'

BASE_DIR = Path(__file__).resolve().parent.parent

SECRET_KEY = 'd87%15x3pBU7*k&@L11PkBtn38oQiNhJ2IX9iqA8d0p%sfikc2m@5p'

DEBUG = True
ALLOWED_HOSTS = [
   'emploisquebec.net'
]


# Application definition

INSTALLED_APPS = [
    'debug_toolbar',
    'filemanager',
    'filer',
    'easy_thumbnails',
    'emplois.apps.EmploisConfig',
    'splashpage',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'bootstrap5',
]

MIDDLEWARE = [
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'emploiquebec.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / "templates"],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

FILER_SERVERS = {
    'private': {
        'main': {
            'ENGINE': 'filer.server.backends.xsendfile.ApacheXSendfileServer',
            },
        'thumbnails': {
            'ENGINE': 'filer.server.backends.xsendfile.ApacheXSendfileServer',
            },
        },
    }

WSGI_APPLICATION = 'emploiquebec.wsgi.application'

MEDIA_ROOT = '/usr/home/sixpiece/python/emploiquebec/media'

MEDIA_URL = '/media/'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

THUMBNAIL_HIGH_RESOLUTION = True

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters',
)

FILER_ENABLE_PERMISSIONS = True

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',

    },
]


LANGUAGE_CODE = 'de-de'

TIME_ZONE = 'Berlin/Europe'

USE_I18N = True

USE_TZ = True

STATIC_URL = '/static/'
STATIC_ROOT = BASE_DIR / 'staticfiles/'

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

FILER_STORAGES = {
    'public': {
        'main': {
            'ENGINE': 'filer.storage.PublicFileSystemStorage',
            'OPTIONS': {
                'location': '/home/sixpiece/python/emploiquebec/media/filer',
                'base_url': '/media/filer/',
            },
            'UPLOAD_TO': 'filer.utils.generate_filename.randomized',
            'UPLOAD_TO_PREFIX': 'filer_public',
        },
        'thumbnails': {
            'ENGINE': 'filer.storage.PublicFileSystemStorage',
            'OPTIONS': {
                'location': '/home/sixpiece/python/emploiquebec/media/filer_thumbnails',
                'base_url': '/media/filer_thumbnails/',
            },
        },
    },
    'private': {
        'main': {
            'ENGINE': 'filer.storage.PrivateFileSystemStorage',
            'OPTIONS': {
                'location': '/usr/home/sixpiece/python/emploiquebec/smedia/filer',
                'base_url': '/smedia/filer/',
            },
            'UPLOAD_TO': 'filer.utils.generate_filename.randomized',
            'UPLOAD_TO_PREFIX': 'filer_public',
        },
        'thumbnails': {
            'ENGINE': 'filer.storage.PrivateFileSystemStorage',
            'OPTIONS': {
                'location': '/usr/home/sixpiece/python/emploiquebec/smedia/filer_thumbnails',
                'base_url': '/smedia/filer_thumbnails/',
            },
        },
    },
}

@prepstarr
Copy link
Author

here's the issue as far as I see... is the thumbnail

'filer.thumbnail_processors.scale_and_crop_with_subject_location', will not work but if I use

'easy_thumbnails.processors.scale_and_crop', then it works.... cause it gives a different location

@prepstarr
Copy link
Author

for example it looks for this thumbnail : https://tld-withheld.net/media/filer_public_thumbnails/filer_public/fb/5b/fb5bdd6d-9a78-4a7c-ab42-39c41d3b510b/sheldon-lub.png__40x40_q85_crop_subsampling-2.jpg

sheldon-lub.png__40x40_q85_crop_subsampling-2.jpg a little bit odd...

@prepstarr
Copy link
Author

I set it back to 'filer.thumbnail_processors.scale_and_crop_with_subject_location' what I notice is that the minute it uploads the picture it's there but if I refresh it's gone...

@prepstarr
Copy link
Author

(env) $ python manage.py filer_check --orphans
Traceback (most recent call last):
  File "/usr/home/sixpiece/python/emploiquebec/manage.py", line 22, in <module>
    main()
  File "/usr/home/sixpiece/python/emploiquebec/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/usr/home/sixpiece/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/usr/home/sixpiece/env/lib/python3.9/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/home/sixpiece/env/lib/python3.9/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/home/sixpiece/env/lib/python3.9/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/usr/home/sixpiece/env/lib/python3.9/site-packages/filer/management/commands/filer_check.py", line 66, in handle
    self.verify_storages(options)
  File "/usr/home/sixpiece/env/lib/python3.9/site-packages/filer/management/commands/filer_check.py", line 114, in verify_storages
    walk(filer_public['UPLOAD_TO_PREFIX'])
  File "/usr/home/sixpiece/env/lib/python3.9/site-packages/filer/management/commands/filer_check.py", line 95, in walk
    child_dirs, files = storage.listdir(prefix)
  File "/usr/home/sixpiece/env/lib/python3.9/site-packages/django/core/files/storage/filesystem.py", line 170, in listdir
    with os.scandir(path) as entries:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/home/sixpiece/python/emploiquebec/media/filer_public'

@prepstarr
Copy link
Author

apologize for the fatigure of the other I was up late doing the system upgrades, etc..

@prepstarr
Copy link
Author

it's missing filer_thumbnails in the path... between /media/"missing here"/filer_public_thumbnails ...

@fsbraun
Copy link
Member

fsbraun commented Aug 20, 2023

Your settings look good to me.

Just to nail this down: I assume the issue disappears if you remove your custom thumbnail filer storage? If so, I assume there is a bug using the wrong storage (default storage as opposed to thumbnail storage). Can you confirm?

@prepstarr
Copy link
Author

yes that is correct, on new pictures if I comment out the thumbnail storage it will work properly...

@prepstarr
Copy link
Author

it seems to fix the issue... in fact because by selecting the image it will recreate the thumbnail and it will work... should I close this issue?

@prepstarr
Copy link
Author

thank you...

@prepstarr
Copy link
Author

image

@fsbraun
Copy link
Member

fsbraun commented Aug 20, 2023

I think you found a real bug: If you have a custom file storage for thumbnails, it needs to be reflected in the directory listing. Leave this issue open.

@fsbraun
Copy link
Member

fsbraun commented Aug 20, 2023

I would like to come up with a fix. Once I've done that, could you test it with your original settings?

@fsbraun fsbraun transferred this issue from django-cms/django-cms Aug 20, 2023
fsbraun added a commit to fsbraun/django-filer that referenced this issue Aug 20, 2023
@fsbraun
Copy link
Member

fsbraun commented Aug 20, 2023

Here's a fix: #1413

Can you test if it works with your original settings? You can install the fix using pip install git+https://github.com/fsbraun/django-filer@fix/respect_storage_settings.

@prepstarr
Copy link
Author

no it's not working...

@prepstarr
Copy link
Author

(env) $ pip install git+https://github.com/fsbraun/django-filer@fix/respect_storage_settings
Collecting git+https://github.com/fsbraun/django-filer@fix/respect_storage_settings
  Cloning https://github.com/fsbraun/django-filer (to revision fix/respect_storage_settings) to /tmp/pip-req-build-_9wz1bv2
  Running command git clone --filter=blob:none --quiet https://github.com/fsbraun/django-filer /tmp/pip-req-build-_9wz1bv2
  Running command git checkout -b fix/respect_storage_settings --track origin/fix/respect_storage_settings
  Switched to a new branch 'fix/respect_storage_settings'
  branch 'fix/respect_storage_settings' set up to track 'origin/fix/respect_storage_settings'.
  Resolved https://github.com/fsbraun/django-filer to commit efbd71e7d454ccb1463db6631f9415b3ab6dcada
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: django<5,>=3.2 in /usr/home/sixpiece/env/lib/python3.9/site-packages (from django-filer==3.0.4) (4.2.4)
Requirement already satisfied: django-polymorphic in /usr/home/sixpiece/env/lib/python3.9/site-packages (from django-filer==3.0.4) (3.1.0)
Requirement already satisfied: easy-thumbnails[svg] in /usr/home/sixpiece/env/lib/python3.9/site-packages (from django-filer==3.0.4) (2.8.5)
Requirement already satisfied: asgiref<4,>=3.6.0 in /usr/home/sixpiece/env/lib/python3.9/site-packages (from django<5,>=3.2->django-filer==3.0.4) (3.7.2)
Requirement already satisfied: sqlparse>=0.3.1 in /usr/home/sixpiece/env/lib/python3.9/site-packages (from django<5,>=3.2->django-filer==3.0.4) (0.4.4)
Requirement already satisfied: pillow in /usr/home/sixpiece/env/lib/python3.9/site-packages (from easy-thumbnails[svg]->django-filer==3.0.4) (10.0.0)
Requirement already satisfied: svglib in /usr/home/sixpiece/env/lib/python3.9/site-packages (from easy-thumbnails[svg]->django-filer==3.0.4) (1.5.1)
Requirement already satisfied: reportlab in /usr/home/sixpiece/env/lib/python3.9/site-packages (from easy-thumbnails[svg]->django-filer==3.0.4) (4.0.4)
Requirement already satisfied: typing-extensions>=4 in /usr/home/sixpiece/env/lib/python3.9/site-packages (from asgiref<4,>=3.6.0->django<5,>=3.2->django-filer==3.0.4) (4.7.1)
Requirement already satisfied: lxml in /usr/home/sixpiece/env/lib/python3.9/site-packages (from svglib->easy-thumbnails[svg]->django-filer==3.0.4) (4.9.3)
Requirement already satisfied: tinycss2>=0.6.0 in /usr/home/sixpiece/env/lib/python3.9/site-packages (from svglib->easy-thumbnails[svg]->django-filer==3.0.4) (1.2.1)
Requirement already satisfied: cssselect2>=0.2.0 in /usr/home/sixpiece/env/lib/python3.9/site-packages (from svglib->easy-thumbnails[svg]->django-filer==3.0.4) (0.7.0)
Requirement already satisfied: webencodings in /usr/home/sixpiece/env/lib/python3.9/site-packages (from cssselect2>=0.2.0->svglib->easy-thumbnails[svg]->django-filer==3.0.4) (0.5.1)

@fsbraun
Copy link
Member

fsbraun commented Aug 20, 2023

This install looks all right. To be on the safe side, you might try uninstalling filer beforehand (pip uninstall django-filer) and then reinstall from the repo. I think it should now respect your custom filer storage settings (and add the missing filer_thumbnails to the thumbnail URL.

I guess we should also have a test for that.

@prepstarr
Copy link
Author

prepstarr commented Aug 20, 2023

image
thank you it seems to be working now... should I close the issue now?

@fsbraun
Copy link
Member

fsbraun commented Aug 20, 2023

Let's leave this open until the fix is merged :-) Thank you for your help! Great work!

@prepstarr
Copy link
Author

you're welcome, thank you for the help as well..

fsbraun added a commit that referenced this issue Aug 22, 2023
* Fix #1377

* fix bug #1412

* Fix: differentiate source_storage and thumbnail_storage

* Update tests to run on non-standard storage settings.

* Update CHANGELOG.rst

* Replace `re_path` by `path`

* Remove `re_path` from tests

* Bump version
@fsbraun fsbraun closed this as completed Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants