Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#21053 closed defect (bug) (duplicate)

Backwards logic in get_attachment_template

Reported by: jfarthing84's profile 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 13 years ago.
Reverse order of attachment template hierarchy.
template.php.2.patch (971 bytes) - added by jfarthing84 13 years ago.
Change underscore to dash in most specific scenario of attachment template.

Download all attachments as: .zip

Change History (5)

@jfarthing84
13 years ago

Reverse order of attachment template hierarchy.

#1 @jfarthing84
13 years 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.

@jfarthing84
13 years ago

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

#3 @nacin
13 years 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.