Closed henningbra closed 1 year ago
Hello @henningbra just to clarify you wish to serve 3 different variants off the same field ? Or you need 3 fields each with its own variant ?
Let me know
Former
EDIT: 3 different variants off the same field for faster loading times. Have checked tests and tried lots of different methods to make it work to no avail.
Below property works. It would be possible to make a template tag passing in a variable from the below.
@property
def url_custom(self):
return f'{self.image.url.rsplit("/", 1)[0]}/custom'
Id that's the cleanest I will proceed.
Hi @henningbra I think in your case, the best would be to add either:
3 functions in your model, like get_small_image_url
so you can avoid parameters
Both would work in a template
@hnb2 Wouldn't it be possible to add a function that accepts the variant as argument and returns the variant URL instead of hardcoding it in the model definition? (Use case could be different thumbnail sizes of the same picture, etc)
May I ask how to serve more than one variant, using a list of [small, medium, large] preregistered variants in Cloudflare Images. How to manipulate the url?