I am trying to make a URL for either the DFI or the normal featured image. I know that I need to reference the the ID but am uncertain how to generate the rest of the URL. Place it into the $thumb_url
variable below so it goes to my websocket appropriately.
The best I achieved was getting a “default.jpg” at one point but it was essentially just a default missing image icon.
if ( $new_status != 'publish' || $old_status == 'publish' || $post->post_type != 'post')
return;
$webhookURL = get_option('discord_webhook_url');
$id = $post->ID;
//$author = $post->post_author;
//$authorName = get_the_author_meta('display_name', $author);
$postTitle = $post->post_title;
$permalink = get_permalink($id);
$thumb_url = "default-or-featured-image-url";
$description = $post->post_excerpt;
$timestamp = $post->post_date;
$postData = json_encode([
"content" => "@here A dragonet just dropped off a new parchment: ",
//"avatar_url" => "image url here",
// Embeds Array
"embeds" => [
[
"title" => $postTitle,
"type" => "rich",
"description" => $description,
"url" => $permalink,
"timestamp" => $timestamp,
"color" => hexdec( "3366ff" ),
"footer" => [
"text" => "EoN Creations - https://eoncreations.com",
"icon_url" => "https://eoncreations.com/wp-content/uploads/2020/02/cropped-EggOracle-180x180.png"
],
"image" => [
"url" => $thumb_url
],
"thumbnail" => [
"url" => $permalink
]
]
]
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );