[wp-trac] [WordPress Trac] #61133: Update `get_attachment_link()` to return image URL when attachment pages are turned off.

WordPress Trac noreply at wordpress.org
Thu May 2 23:50:08 UTC 2024


#61133: Update `get_attachment_link()` to return image URL when attachment pages
are turned off.
---------------------------+------------------------------
 Reporter:  peterwilsoncc  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Media          |     Version:  6.4
 Severity:  normal         |  Resolution:
 Keywords:  needs-patch    |     Focuses:  sustainability
---------------------------+------------------------------
Changes (by azaozz):

 * keywords:   => needs-patch


Old description:

> `get_attachment_link()` returns the URL for the attachment page. As these
> pages have been removed on new installs of WordPress the returned URL
> links to a page that subsequently redirects to the image. This produces
> unnecessary computing cycles and delays visitors reaching the eventual
> destination.
>
> When attachment pages are turned off, the function should return the same
> value as `wp_get_attachment_url()`.
>
> Follow up to [57913].

New description:

 `get_attachment_link()` returns the URL for the attachment page. As these
 pages have been removed on new installs of WordPress the returned URL
 links to a page that subsequently redirects to the image. This produces
 unnecessary computing cycles and delays visitors reaching the eventual
 destination.

 When attachment pages are turned off, the function should return the same
 value as `wp_get_attachment_url()`.

 Follow up to #57913.

--

Comment:

 Yep, makes sense to avoid the redirect and improve performance. Could
 potentially be a little unexpected when the link is not to an image but to
 another type of file, but seems this is the case already.

 Also fixed a typo in the description, assuming the link is to ticket 57913
 where this was implemented.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61133#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list