Closed melinath closed 9 years ago
Can you briefly articulate what the change in the API here is? I think this seems like a good change, but I don't totally understand it. And we'll also want it documented for release notes.
This is an undocumented API, so I don't know if we neeeed to document the change, but I could.
Essentially, instead of creating adjustment instances ahead of time and passing in a list, you now call a method on the adjustment helper to look up and add adjustments later.
So old way:
crop = Crop(width=50)
fill = Fill(width=25, height=25)
helper = AdjustmentHelper([instance], [crop, fill])
New way:
helper = AdjustmentHelper([instance])
helper.adjust('crop', width=50).adjust('fill', width=25, height=25)
There's also a change in how to access the adjusted images. Used to be you'd call the .info_dicts() method:
helper = AdjustmentHelper([instance], [crop, fill])
info_dicts = helper.info_dicts()
for instance, info_dict in info_dicts:
# do a thing
Now you can just slice / get / iterate the helper object:
helper = AdjustmentHelper([instance])
for instance, info_dict in helper:
# Do a thing
There's also an additional keyword argument on instantiation (generate=True
) which you can use to specify whether the helper should actually perform adjustments or provide links to perform them later.
Very cool. I'll merge it.
This API seems more understandable, and will also allow incremental adjustment application (for example, via template filters).