Opened 9 years ago
Last modified 5 years ago
#36270 new enhancement
Allow filtering of the final HTML output of media related shortcodes
Reported by: | gnotaras | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 4.7.2 |
Component: | Media | Keywords: | needs-patch |
Focuses: | Cc: |
Description
Sometimes it is required to further process the final HTML output of the media related shortcodes, eg caption
or gallery
, so as to add extra HTML code such as enclosing div or span elements or just modify the existing HTML code during run time.
For instance the final output of img_caption_shortcode
could be filtered:
https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-includes/media.php#L1537
Passing all relevant image attachment data, like ID and size, would also be very useful.
I hope that I am not missing anything but right now the only way to insert code inside the <figure>
or <figcaption>
block seems to be the complete override of the img_caption_shortcode
function.
Change History (5)
#4
@
5 years ago
Hello,
I created a filter to allow caption customisation. Here's the Gist.
https://gist.github.com/marklchaves/1116bba6fcd9688b4df5b121d5d76277
This Gist has two screen grabs.
- Gallery with the media attachment title and caption displayed using default formatting.
- Gallery with the media attachment title, caption, and description using a styled
H4
captiontag
.
I'd like to submit a pull request if you feel this is worthy.
Thanks for your time!
Related: #14130, #20230, #29832.