Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Use Python path functions in image styles #48

Closed
Wtower opened this issue Mar 29, 2016 · 0 comments
Closed

Use Python path functions in image styles #48

Wtower opened this issue Mar 29, 2016 · 0 comments
Assignees
Milestone

Comments

@Wtower
Copy link
Owner

Wtower commented Mar 29, 2016

The image_style function of utils/media.py is responsible for generating image styles.

It currently utilises the linux file name conventions explicitly, which makes this function unavailable to Windows.

Also, the way that the paths are constructed is not Pythonic and causes trouble to the tests in #44 as the media root there is different than as assumed in most projects.

Method:

  • Instead of passing the url string pass the ImageField object itself in order to use the file property (instead of the url property that was used in templates).
  • Then return the appropriate url.
  • Also change the templatetags to remove the @stringfilter and the variable names to reflect the change.
  • Consequently, the image_style_form template tag is now obsolete. This was totally unnecessary anyway, the initial reasoning was that form imagefields are different objects but the ImageField object can be obtained from them.
  • Change the block_static.html example template from <img src="{{ img.image.url|image_style:'large' }}"> to <img src="{{ img.image|image_style:'large' }}">
  • Change the templates stacked.html that displays thumbnails in node editing from <img src="{{ inline_admin_form.form.image.value|image_style_form:'thumbnail' }}"> to <img src="{{ inline_admin_form.form.image.value|image_style:'thumbnail' }}"> (the value property is the underlying model ImageField in the form ImageField).
  • Update CHANGELOG and make note that when updating 9cms, this is requires manual updates to all templates using images styles.
@Wtower Wtower self-assigned this Mar 29, 2016
@Wtower Wtower added this to the v0.6.0 milestone Mar 29, 2016
Wtower added a commit that referenced this issue Mar 29, 2016
Wtower added a commit that referenced this issue Mar 30, 2016
@Wtower Wtower closed this as completed Mar 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant