Skip to content

Commit

Permalink
fix: Add width and height fields to inline form
Browse files Browse the repository at this point in the history
  • Loading branch information
fdintino committed Sep 20, 2023
1 parent a1482bd commit 3830fb3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cropduster/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def get_cropduster_field_on_model(model, field_identifier):
class CropDusterInlineFormSet(BaseGenericFileInlineFormSet):

fields = ('image', 'thumbs', 'attribution', 'attribution_link',
'caption', 'alt_text', 'field_identifier')
'caption', 'alt_text', 'field_identifier', 'width', 'height')

def __init__(self, *args, **kwargs):
super(CropDusterInlineFormSet, self).__init__(*args, **kwargs)
Expand Down
8 changes: 8 additions & 0 deletions cropduster/static/cropduster/css/cropduster.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@

.cropduster-form .image,
.cropduster-form .thumbs,
.cropduster-form .width,
.cropduster-form .height,
.cropduster-form .DELETE,
.cropduster-form .field_identifier,
.cropduster-form .field-image,
.cropduster-form .field-thumbs,
.cropduster-form .field-width,
.cropduster-form .field-height,
.cropduster-form .field-field_identifier,
.cropduster-form .inline-related .grp-collapse-handler {
display: none;
Expand All @@ -33,8 +37,12 @@

body.cropduster-debug .cropduster-form .image,
body.cropduster-debug .cropduster-form .thumbs,
body.cropduster-debug .cropduster-form .width,
body.cropduster-debug .cropduster-form .height,
body.cropduster-debug .cropduster-form .field-image,
body.cropduster-debug .cropduster-form .field-thumbs,
body.cropduster-debug .cropduster-form .field-width,
body.cropduster-debug .cropduster-form .field-height,
body.cropduster-debug .cropduster-form .DELETE,
body.cropduster-debug .cropduster-form .inline-related .grp-collapse-handler {
display: block !important;
Expand Down
2 changes: 2 additions & 0 deletions cropduster/static/cropduster/js/cropduster.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ window.CropDuster = {};
$('#id_' + prefix + '-INITIAL_FORMS').val('0');
}
$('#id_' + prefix + '-0-image').val(data.crop.orig_image);
$('#id_' + prefix + '-0-width').val(data.crop.orig_w);
$('#id_' + prefix + '-0-height').val(data.crop.orig_h);
$('#id_' + prefix).val(data.crop.orig_image);
$('#id_' + prefix + '-TOTAL_FORMS').val('1');
if (typeof data.thumbs != 'object') {
Expand Down

0 comments on commit 3830fb3

Please sign in to comment.