Skip to content

Instantly share code, notes, and snippets.

@palmiak

palmiak/functions.php Secret

Created Dec 1, 2019
Embed
What would you like to do?
<?php
// a small fix to thumbnail function - get_thumbnail_image generates srcset and sizes - which the feed doesn't want.
// Display featured post thumbnails in WordPress feeds
function wpbuilds_post_thumbnails_in_feeds( $content ) {
global $post;
$post_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
if( '' !== $post_thumb[0] ) {
$content = '<div><img src="' . $post_thumb[0] . '" style="margin-bottom:15px" alt=""/></div>' . $content;
}
return $content;
}
add_filter( 'the_excerpt_rss', 'wpbuilds_post_thumbnails_in_feeds' );
add_filter( 'the_content_feed', 'wpbuilds_post_thumbnails_in_feeds' );
<?php
/**
* Plugin Name: [Smush Pro] - Skip lazy in feeds
* Plugin URI: https://premium.wpmudev.org/
* Description: Turns off lazy loading.
* Author: Maciek Palmowski @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
*/
add_action( 'wp', function() {
if( is_feed() ) {
add_filter( 'smush_skip_image_from_lazy_load', '__return_true' );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.