Last active
February 1, 2022 15:36
-
-
Save websupporter/384face6ae26700fb280 to your computer and use it in GitHub Desktop.
Change the oEmbed output of WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'oembed_response_data', 'fwe_oembed_response_data', 11, 4 ); | |
function fwe_oembed_response_data( $data, $post, $width, $height ){ | |
if ( ! is_object( $post ) ) | |
return $data; | |
if( ! has_post_thumbnail( $post->ID ) ) | |
return $data; | |
$thumbnail_id = get_post_thumbnail_id( $post->ID ); | |
$image = wp_get_attachment_image_src( $thumbnail_id, 'full' ); | |
$data = array( | |
'version' => '1.0', | |
'provider_name' => get_bloginfo( 'name' ), | |
'provider_url' => get_home_url(), | |
'author_name' => get_bloginfo( 'name' ), | |
'author_url' => get_home_url(), | |
'title' => $post->post_title, | |
'type' => 'photo', | |
'url' => $image[0], | |
'width' => $image[1], | |
'height' => $image[2], | |
); | |
return $data; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment