Dashboard product list is unusable if an image is missing
See original GitHub issueIssue Summary
Thanks for introducing the thumbnailing abstraction. It’s something we’ve always wanted to do! Unfortunately, I think I found a small regression.
On one of my Oscar staging sites, not all images that are in the database are actually on disk. This leads to display errors in the frontend. More importantly, the product list in the dashboard becomes totally unusable, because an exception is thrown.
The exception is thrown if thumb.height
or thumb.width
are accessed. And indeed, product_row_image.html
(the dashboard template) accesses those, and the storefront gallery.html
doesn’t. That’s why the storefront only has display errors, but the backend throws an exception.
I wanted to work around this by checking {% if thumb %}
, but that check always succeeds. My workaround is to remove the height and width section from the template. That template is the only place where thumb.height
and width
are accessed.
IIRC, Oscar used to handle this more gracefully. AbstractProduct.get_missing_image
and the MissingProductImage
class were introduced back in the days to pass a special hardcoded image through the thumbnailer. I think they’re still present, but not used. That way, display errors were avoided.
There are a few ways to fix this. I’m happy to assist, but have not worked on the new thumbnail abstraction, so would like some guidance on what the right fix is. The missing image approach was nice when it worked, but getting the file into the media folder was tricky. So I’m not convinced it’s the right approach. What I do know is that accessing a missing image should never keep the site from working.
Steps to Reproduce
- Make note of the product PK of the first product with an image in the dashboard product list.
- Use the Django shell to get the primary key of the
ProductImage
for that product. - In the database, change
catalogue_productimage.original
to a non-existent path. - Access that product in the frontend, and then in the dashboard product list.
Technical details
- Python version: 3.8.5
- Django version: 2.2.21
- Oscar version: 2.1.1 (
image_tags.py
andproduct_row_image.html
are unchanged on master, so I presume the issue still exists)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top GitHub Comments
@solarissmoke Thanks for the prompt reply!
OSCAR_THUMBNAIL_DEBUG
is one of the first things I tried, because of the code inimage_tags.py
. But I’ve just verified again, settingTHUMBNAIL_DEBUG
andOSCAR_THUMBNAIL_DEBUG
toFalse
have no effect. AndDEBUG=False
only means I don’t get a stacktrace - the exception is still thrown. I also know that the staging site where this was originally discovered runs withDEBUG=False
.get_missing_image
is still used, here, if a product has no images?Agree with removing width/height attrs - PR welcome for that!