Make WordPress Core

Opened 7 years ago

Closed 18 months ago

#41461 closed enhancement (wontfix)

Sort out missing attachment.php template somehow

Reported by: mor10's profile mor10 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-screenshots
Focuses: Cc:


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 7 years ago.
Preview of Twenty Seventeen on an attachment

Download all attachments as: .zip

Change History (7)

#1 @johnbillion
7 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
7 years ago

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 post/page? Displaying of the post/page content?
I know the next and prev image navigation could use some markup.

Last edited 7 years ago by poena (previous) (diff)

#3 @mor10
7 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
7 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.

7 years ago

Preview of Twenty Seventeen on an attachment

#5 @grapplerulrich
7 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.

#6 @desrosj
18 months ago

  • Keywords has-screenshots added; close removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Came across this one doing some triage on tickets marked close.

I have to agree, it's not clear what "broken" or "supported" even means here. If I had to guess, users are seeing full URLs, and large titles (cropped-6c2f1e33-d493-3917-bda6-bcc1dd4d6102.jpg in the screenshot above), etc.

With the arrival of the site editor, I don't think it's worth investing the time figuring out how to determine if a classic PHP-based theme supports attachments (whatever that may mean). If this is still a problem in modern, block theme based WordPress sites, an issue should be opened upstream in the Gutenberg GitHub repository.

Note: See TracTickets for help on using tickets.