Activity › Forums › Astrofotografie › Deepsky › NGC2264 Complex › Reply To: NGC2264 Complex
March 4, 2017 at 02:29
#12432
Participant
@keesscherer Gefelicteerd :-) .
http://eapod.eu/4-march-2017-ngc-2264-complex/
@eapod Als het image tevens als Featured Image wordt ingesteld is de preview binnen WP sites mooier (lees, de afbeelding is zichtbaar). Dit is makkelijk te automatiseren door dit stukje code toe te voegen aan functions.php in de child-themes folder (getest). Als het Featured Image wel is ingesteld in de posts is het wellicht de eerder besproken: hotlink protection in Cloudflare? Hoe dan ook, het script is erg handig :-)
function auto_featured_image() {
global $post;
if (!has_post_thumbnail($post->ID)) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}
}
}
}
// Use it temporary to generate all featured images
add_action('the_post', 'auto_featured_image');
// Used for new posts
add_action('save_post', 'auto_featured_image');
add_action('draft_to_publish', 'auto_featured_image');
add_action('new_to_publish', 'auto_featured_image');
add_action('pending_to_publish', 'auto_featured_image');
add_action('future_to_publish', 'auto_featured_image');

