Skip to content

Instantly share code, notes, and snippets.

@ippeiukai
ippeiukai / functions.php
Last active July 23, 2023 09:32 — forked from tilap/functions.php
Wordpress: How to automatically attache youtube/vimeo thumbnail as a post feature image from a post meta key
<?php
// https://github.com/WebDevStudios/Automatic-Featured-Images-from-Videos/blob/1.2.0/automatic-featured-images-from-videos.php
/**
* If a YouTube or Vimeo video is added in the post content, grab its thumbnail and set it as the featured image.
*
* @since 1.0.0
*
* @param int $post_id ID of the post being saved.
* @param string $video_thumbnail_url URL of the image thumbnail.