WordPress.org

Make WordPress Core

#21053 closed defect (bug) (duplicate)

Backwards logic in get_attachment_template

Reported by: jfarthing84 Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: Template Keywords: has-patch
Focuses: Cc:

Description

It seems to me that the logic in get_attachment_template is backwards. Aren't templates supposed to go from specific to general? All others do, except attachments. Let's fix that.

Attachments (2)

template.php.patch (894 bytes) - added by jfarthing84 22 months ago.
Reverse order of attachment template hierarchy.
template.php.2.patch (971 bytes) - added by jfarthing84 22 months ago.
Change underscore to dash in most specific scenario of attachment template.

Download all attachments as: .zip

Change History (5)

jfarthing8422 months ago

Reverse order of attachment template hierarchy.

comment:1 jfarthing8422 months ago

Also just noticed that with the most specific template, the intended result isn't even used. For instance, a JPEG image would be image_jpeg.php. However, get_query_template uses a regular expression that removes the underscore, thus changing the template it looks for to imagejpeg.php. I suggest that the underscore be changed to a dash, thus matching the WordPress file naming convention and avoiding this problem.

jfarthing8422 months ago

Change underscore to dash in most specific scenario of attachment template.

comment:3 nacin22 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This is a duplicate of #15337. Your insight in comment:1 here could be very helpful there. ("Also just noticed that with the most specific template, the intended result isn't even used.") Can we move the conversation over there?

Note: See TracTickets for help on using tickets.