django-master / django-webp

Speeds up static file load times by generating a webp image to load to a webpage instead of a jpg, gif or png
MIT License
36 stars 14 forks source link

WEBP image could not be saved in #43

Open MichaelOC05 opened 1 year ago

MichaelOC05 commented 1 year ago

I am using Pillow 10.0.0, whitnoise 6.5.0, Django 4.2.3, django-webp 2.1.1.

When running locally with the no WEBP_CACHE the images are created in WEB_CACHE/images but are not accessible. Log output is Not Found: /static/WEBP_CACHE/filename. If I restart the application images that have been created in the WEB_CACHE/images directory are loaded, however images that have not been created in this directory will not load. They will load if the application is restarted again.

I was mostly able to fix this by creating a python command that looped through the images in the static directory and called the webp function in dajngo_webp.tempatetags.webp.py.

When deployed if I run this custom command or if I attempt to use the package as it is I get and error WEBP image could not be saved in app/project/staticfiles/WEBP_CACHE/images/imagename. The deployment is to openshift.

When I run collectstatic the path is "/app/project_nam/staticfiles", could the slash at the beginning be the difference?

bimmui commented 1 year ago

Hey Michael,

I was able to replicate the error locally and I'm currently working on a solution to it. Could you provide a bit of info on how you have your static files set up in your production sever? I'm mainly just looking for what you have STATIC_URL, STATIC_ROOT, and STATICFILES_DIRS set to.

MichaelOC05 commented 1 year ago

Yeah no problem, STATIC_URL = "static/" STATIC_ROOT = BASE_DIR / "staticfiles" STATICFILES_DIR = [BASE_DIR / "static"]. Thanks for looking into this

MichaelOC05 commented 1 year ago

Hi sorry I was wondering if you were able to make any headway with this issue?