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

ImagesPipeline.thumb_path should allow access to item #5504

Closed
sliverc opened this issue May 20, 2022 · 0 comments · Fixed by #5508
Closed

ImagesPipeline.thumb_path should allow access to item #5504

sliverc opened this issue May 20, 2022 · 0 comments · Fixed by #5508

Comments

@sliverc
Copy link

sliverc commented May 20, 2022

Summary

ImagesPipeline should pass on item to thumb_path function as additional argument.

Motivation

The ImagesPipeline.file_path function allows access to item. So when an user overwrites this function and makes the file name
depended on the item itself, it makes sense to have the thumb path to be depended on the item as well.

This way main image file and thumbnail image file can have the same name and it is easily possible to jump between different sizes of the image.

Example of how a file and thumbnail could be build:

file_path = f"full/{item['ID']}.jpg"
thumb_path = f"thumbs/small/{item['ID']}.jpg"

So I suggest to change the signature of ImagesPipeline.thumb_path to the following:

def thumb_path(self, request, thumb_id, response=None, info=None, *, item=None):

which makes the functions thumb_path and file_path more consistent.

Describe alternatives you've considered

As a workaround when I overwrite file_path I set request._item = item which I can then access in thumb_path function.

Additional context

In case this is of interest I am happy to work on a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants