New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Allow thumbnails to be chosen from Wagtail image chooser #64
Comments
Hey @juan0tron, This is rather late, but you can create your own media form and set in settings via With that you could specify your own widget |
I intended to submit a PR that documents what we had to do to get this to work, but then I saw the "Upcoming breaking changes affecting Wagtail community projects", which warns against directly linking to Wagtail JS/CSS. We had to create a custom image chooser which links to a few Wagtail JS files to get this working, so we might need to hold off on documenting this until the front-end changes land upstream. Here is an example of what we did: class CustomImageChooser(AdminImageChooser):
@property
def media(self):
return forms.Media(js=[
versioned_static('wagtailadmin/js/modal-workflow.js'),
versioned_static('wagtailimages/js/image-chooser-modal.js'),
versioned_static('wagtailimages/js/image-chooser.js'),
]) I'd have to dig through my notes but my recollection is that AdminImageChooser implicitly relies on JS files already loaded in the Wagtail admin templates, so we had to explicitly load these files to get it to work. Obviously, if we did this the hard way, happy to learn of a simpler approach! And equally happy to work on a PR to document this the "right" way once that has been defined upstream. Thanks! |
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
informs.py
?For example:
Then in my custom model:
The text was updated successfully, but these errors were encountered: