my client want me to add a custom fields for thumbail, so the logic will be
if custom_thumnail is empty, render the origina. But i don't like idea of writing if statments everywhere + am using SEO plugins for open graph and images, so now i have to use filters to implement the custom thumbail.
i was thinking of wp filters but i didn't find one for get_the_post_thumbnail.
apply_filter('get_the_post_thumbnail',function(){
//my if statments
})
my client want me to add a custom fields for thumbail, so the logic will be
if custom_thumnail is empty, render the origina. But i don't like idea of writing if statments everywhere + am using SEO plugins for open graph and images, so now i have to use filters to implement the custom thumbail.
i was thinking of wp filters but i didn't find one for get_the_post_thumbnail.
apply_filter('get_the_post_thumbnail',function(){
//my if statments
})
You can use the post_thumbnail_html
filter.
This filter is applied in the return of the get_the_post_thumbnail
function.
apply_filters( 'post_thumbnail_html', $html, $post->ID, $post_thumbnail_id, $size, $attr );