In my custom media model, I would like to allow my users to select their thumbnails from their existing image library. While it's possible to override the "thumbnail" field with the wagtailimages model, it does not look like it is possible to enable the ImageChooserPanel widget on the edit form (therefore making it impossible to choose an image/actually use the image model).
I understand this may be more of a limitation of Wagtail than of this package, since Wagtail does not allow you to specify a widget under admin_form_fields. (See wagtail/wagtail#2610)
Would it be possible to provide an override the "widgets" object under get_media_form in forms.py?
For example:
# wagtailmedia/forms.py
# ...
def get_media_form(model):
# ...
if (not model.custom_widgets):
widgets = {
'tags': widgets.AdminTagWidget,
'file': forms.FileInput(),
'thumbnail': forms.ClearableFileInput(),
}
else:
widgets = custom_widgets
return modelform_factory(
model,
form=BaseMediaForm,
fields=fields,
widgets=)
Then in my custom model:
from wagtail.images.fields import WagtailImageField
# other imports
class CustomMedia(AbstractMedia):
# Override the "thumbnail" field to use my custom Wagtail Images model
thumbnail = models.ForeignKey(
'images.CustomImage',
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name='+'
)
admin_form_fields = (
'title',
'file',
'thumbnail',
'collection',
'tags',
)
custom_widgets = {
'tags': widgets.AdminTagWidget,
'file': forms.FileInput(),
'thumbnail': WagtailImageField(),
}
In my custom media model, I would like to allow my users to select their thumbnails from their existing image library. While it's possible to override the "thumbnail" field with the wagtailimages model, it does not look like it is possible to enable the ImageChooserPanel widget on the edit form (therefore making it impossible to choose an image/actually use the image model).
I understand this may be more of a limitation of Wagtail than of this package, since Wagtail does not allow you to specify a widget under
admin_form_fields. (See wagtail/wagtail#2610)Would it be possible to provide an override the "widgets" object under
get_media_forminforms.py?For example:
Then in my custom model: