WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 2 years ago

#41461 new enhancement

Sort out missing attachment.php template somehow

Reported by: mor10 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords: close
Focuses: Cc:
PR Number:

Description

When a visitor goes to an attachment page (typically linked from a gallery) and the theme does not have an attachment template, they get a random and most often broken user experience. This is largely due to theme developers not creating an attachment.php template (and starter themes like Underscores not providing one), but it is perceived by visitors and site owners as an error.

There must be some way of gracefully capturing requests for attachment pages when the theme has no support for them so the info is displayed in a non-broken format.

Attachments (1)

attachment.jpeg (167.3 KB) - added by grapplerulrich 2 years ago.
Preview of Twenty Seventeen on an attachment

Download all attachments as: .zip

Change History (6)

#1 @johnbillion
2 years ago

  • Component changed from Media to Themes
  • Keywords close added
  • Type changed from defect (bug) to enhancement
  • Version trunk deleted

None of the default themes since Twenty Fourteen have included an attachment.php template file, but they all correctly handle displaying attachments (at least, image attachments) via template parts that are included in single.php.

Technically, a theme could only include index.php and still gracefully handle the display of attachments.

I think detecting whether or not a theme correctly supports attachments is pretty much impossible. Does the theme review guidelines cover the display of attachments? If not, that would probably be the best approach here.

#2 @poena
2 years ago

Hi
The guidelines does not have any requirements about attachments.
I am not sure how it is broken or what the expectations are?

Navigation to the parent page? Displaying of the page content?
I know the next and prev image navigation could use some markup.

Version 0, edited 2 years ago by poena (next)

#3 @mor10
2 years ago

If the guidelines don't stipulate attachment support, then I would suggest adding it in. Lack of attachment support causes unexpected behavior for a feature built into the very core of WordPress. Attachment pages get far too little love for how prominently they are featured in day-to-day operations within WordPress.

#4 @jcastaneda
2 years ago

Is there a post readily available on how to handle attachments?

I'm not against the teaching of better practices and I think this would be a good one to pass on to theme authors.

@grapplerulrich
2 years ago

Preview of Twenty Seventeen on an attachment

#5 @grapplerulrich
2 years ago

@mor10 Could you elaborate on

they get a random and most often broken user experience.

I have attached a screenshot of how it looks in Twenty Seventeen. I don't see anything broken. Is there a good example that you have seen?

If attachment pages are useful or not are a separate discussion which I have formed a firm opinion on yet.

Note: See TracTickets for help on using tickets.