Building dynamic attachment templates in block themes #192
Locked
justintadlock
started this conversation in
Topic Ideas
Replies: 1 comment
-
Discussion locked, conversation moved to the issue |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Block themes support
attachment.html
templates, but WordPress is not very "smart" about handling the output of media for attachment views. At the moment, there are no dynamic Image, Audio, and Video blocks that automatically pick up the current attachment media file on the front end.Yes, attachments views are now disabled by default for new WP installs (as of 6.4?), but there are still many use cases where attachment templates are needed.
Typically, I don't like to propose topics for the Dev Blog that are outside the standards of theme dev, but this is one of those situations that requires a bit of hacking to make things work as well as they did in classic. That's unfortunate, but this is a missing piece of block theme dev with no instructions/docs (AFAIK) on the best way to handle this.
I'm proposing a tutorial on how to filter the Post Content block for attachment views to insert a sort of dynamic template partial/pattern that allows theme authors to control the output of attachment pages.
I have a working example in my own theme that I could break down for this tutorial:
Beta Was this translation helpful? Give feedback.
All reactions