[wp-trac] [WordPress Trac] #40547: Add a filter to get_the_post_thumbnail_url
WordPress Trac
noreply at wordpress.org
Sun Apr 23 22:46:09 UTC 2017
#40547: Add a filter to get_the_post_thumbnail_url
-----------------------------+-----------------------------
Reporter: ibenic | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Post Thumbnails | Version: trunk
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
Since we have a filter for the function get_the_post_thumbnail:
{{{#!php
return apply_filters( 'post_thumbnail_html', $html, $post->ID,
$post_thumbnail_id, $size, $attr )
}}}
should we also have a filter to the function get_the_post_thumbnail_url?
I have a situation where I have made a plugin that allows setting a
post_thumbnail image as an external url or similar so I am using the
mentioned filter for displaying a custom post thumbnail.
If a theme uses the function get_the_post_thumbnail_url, there is no way
to return the custom url for the post thumbnail.
Something like this could be helpful then:
{{{#!php
function get_the_post_thumbnail_url( $post = null, $size = 'post-
thumbnail' ) {
$post_thumbnail_id = get_post_thumbnail_id( $post );
if ( ! $post_thumbnail_id ) {
return false;
}
return apply_filters( 'get_the_post_thumbnail_url',
wp_get_attachment_image_url( $post_thumbnail_id, $size ), $post->ID );
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40547>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list