Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#7210 closed defect (bug) (worksforme)

Gallery image with file-name that is_numeric() displays 'attachment' in URL

Reported by: na3s Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.5.1
Component: Administration Keywords: gallery, image, attachment, url, upload
Focuses: Cc:


This issue with the gallery came to my attention while helping another wordpress member (CelestialGraffiti) troubleshoot an issue of a bug in the Image Gallery feature. If a user uploads an image with a file-name that is *only* numeric characters, it will display the file as an 'attachment' in the URL; ie sitename.tld/category/page/attachment/1/. However, if the image contains any Alpha characters, the appended 'attachment' is left out of the URL, and is formatted in the intended manor.

This can cause problems in the template; ie: inconsistently showing a 'Comment Form' or other argumentative template elements.

This is a minor issue, but one that is important to address to maintain consistent behavior with the gallery.

Change History (3)

comment:1 @andy7 years ago

The URLs are designed that way. The word "attachment" is added to the path because without it WP_Rewrite doesn't know that the numeric part of the URL refers to an attachment name.

Are these problems caused by core template logic or introduced by specific templates that are unaware of the standard URL pattern for numeric attachment slugs?

comment:2 @na3s7 years ago

I believe this is caused by core template logic. The template was just the indicator. First there was the realization that only *some* of the photos had a comment form, then came the realization that the ones with the comment form had a different URL structure, and shortly after it was realized that uploading a photo with a filename which is only numeric will result in the following instance:

when numeric:
filename = $x.jpg
url = /attachment/$x

when !numeric
filename = %y.jpg
url = /%y.jpg

The template does not determine a URL structure, and therefor this error is more than likely a core bug.

I can't say for sure, but it looks as if the wp_get_attachment_link() function (or one of it's dependencies) is possibly the culprit.

comment:3 @DD327 years ago

  • Milestone 2.9 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

This sounds like a theme issue to me, My theme shows comment forms for /attachment/1234/ urls, and theres nothing special in it..

Note: See TracTickets for help on using tickets.