Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
<?php | |
/* | |
A snippet of code to create static featured images for a WordPress post using | |
a YouTube or Vimeo video URL. I have used this code for several projects where | |
video posts or embedded videos needed to be static images in order to be more | |
mobile friendly as well as for improved page load times when used as a featured | |
image for the post. | |
I have added comments where it might be neccessary to modify the code or where | |
there is room for improvement. There are two primary functions to be used |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
<?php | |
/** | |
* Template Name: ajax | |
*/ | |
?> | |
<?php | |
$post = get_post($_GET['id']); | |
?> | |
<?php if ($post) : ?> | |
<?php setup_postdata($post); ?> |
<?php | |
/* | |
* This function will get the first image in this order: | |
* | |
* 1) Featured image | |
* 2) First image attached to post | |
* 3) First image URL in the content of the post | |
* 4) YouTube screenshot | |
* 5) Default images for different categories [SET MANUALLY] |