Make WordPress Core

Opened 2 years ago

Last modified 8 weeks ago

#57760 new enhancement

add 'pre_wp_get_attachment_url' filter

Reported by: fodisery's profile fodisery Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: Cc:

Description (last modified by sabernhardt)

We are making plugin for featured image using external url.

If user gt featured image url via wp_get_attachment_url() there is no way for us to hook because wp_get_attachment_url hook will never called if the post is not 'attachment'. The only way for us to make it work via creating fake attachment which is complicated.

pre_wp_get_attachment_url filter will be very helpful in this case.

Change History (4)

#1 @fodisery
2 years ago

Real life problem:

https://wordpress.org/plugins/featured-image-from-url/
They solve this by creating fake attachment for each featured image, which waste of space.

https://wordpress.org/plugins/featured-image-by-url/
They stated plugin wont work if theme uses 'wp_get_attachment_url' to get featured image url

#2 @fodisery
23 months ago

even jetpack also have problem hooking photon to wp_get_attachment_url()
https://github.com/Automattic/jetpack/issues/946

#3 @sabernhardt
21 months ago

  • Component changed from General to Media
  • Description modified (diff)

This ticket was mentioned in PR #7853 on WordPress/wordpress-develop by @liamfirth.


8 weeks ago
#4

  • Keywords has-patch added

Adds pre_wp_get_attachment_url filter to short-circuit the wp_get_attachment_url function (allows better use of CDN, shared media library, external URLs, etc).

Trac ticket: https://core.trac.wordpress.org/ticket/57760

Note: See TracTickets for help on using tickets.