[Enhancement] Image carousel - full caption display / functionality #1124
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that there was no ability to show captions for images inserted into the Image Carousel widget, so I have written this functionality. The code itself is based on the caption functionality found in the Image Gallery widget, so for all intents and purposes it functions exactly the same.
The caption is currently inserted as a
<figcaption>element directly inside .slick-slide-inner. Full typographic control can be made on that element (eg color, font size, alignment etc). The content of the caption is sourced from the Media Library "Caption" attribute, just like in the Image Gallery widget.Some basic testing has been done - the only limitation is that the slick.js slide height sets itself to the entirety of the caption + image space. So if there is a particularly lengthy caption in one image, it will create a void underneath the other less lengthy slides. However this also ensures the content beneath the slide doesn't bounce around as different slide heights are brought into view.
This limitation could be solved with better CSS styling (or relocating
figcaptionto a better place in the markup), but the current solution works for now.Please suggest ideas / improvements!
TO-DO / WISHLIST
SCREENSHOTS
Front end:

(Note the gap between the slide image, captions, and controls, caused by the limitation described above. Not a huge issue for most users I imagine, it's only if you happen to abuse the caption feature by adding loads of text...)
Works responsively too
Code structure:

Backend controls:
