Here's what I tried to add a collection of images to a Page #11056
NXPY123
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Looking great @NXPY123! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This solution is based on the code provided by @lukasalexanderweber in issue #9222 raised by him.
Based on the method proposed by him, to add a collection of images to a Page, one can add a
collection
ForeignKey to awagtailcore.collection
in the Page, giving access to all the images in the collection to the Page. A field panel should be added which lets us select the desired collection based on the ones available.The images present in the collection are filtered from all the images in the
Image
model and are passed to the context, which is then used to populate the template while rendering the Page.models.py
templates/page_with_collection.html
Screenshots
Sources:
https://stackoverflow.com/questions/73700668/parentalkey-vs-streamfield/73700979#73700979
https://stackoverflow.com/questions/53560422/how-to-give-user-option-to-select-a-wagtail-collection-of-images-in-page
#9222
https://stackoverflow.com/questions/59935868/using-wagtail-collections-for-images-via-snippet-how-do-you-iterate-through-the
https://docs.wagtail.org/en/v4.0.1/editor_manual/documents_images_snippets/collections.html
Beta Was this translation helpful? Give feedback.
All reactions