mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-17 21:43:20 +09:00
add rss output functions
Checks Settings > Reading. If full text is selected, large image is added to entry content. If Send Images to RSS plugin is active, email size image is added to entry content. If Summary is selected, thumbnail is added to description (excerpt).
This commit is contained in:
@@ -188,4 +188,54 @@ class Display_Featured_Image_Genesis_Output {
|
||||
|
||||
}
|
||||
|
||||
public function maybe_do_feed() {
|
||||
|
||||
$displaysetting = get_option( 'displayfeaturedimagegenesis' );
|
||||
$feed_image = $displaysetting['feed_image'];
|
||||
$rss_option = get_option( 'rss_use_excerpt' );
|
||||
|
||||
if ( ! $feed_image ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( '0' === $rss_option ) {
|
||||
add_filter( 'the_content_feed', array( $this, 'add_image_to_feed' ), 15 );
|
||||
}
|
||||
else {
|
||||
add_filter( 'the_excerpt_rss', array( $this, 'add_image_to_feed' ), 1000, 1 );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function add_image_to_feed( $content ) {
|
||||
|
||||
if ( ! has_post_thumbnail() ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$rss_option = get_option( 'rss_use_excerpt' );
|
||||
$size = 'large';
|
||||
$align = '';
|
||||
$style = 'display:block;margin:10px auto;';
|
||||
$class = 'rss-featured-image';
|
||||
|
||||
if ( class_exists( 'SendImagesRSS' ) ) {
|
||||
$size = 'mailchimp';
|
||||
$class = 'rss-mailchimp';
|
||||
}
|
||||
|
||||
if ( '1' === $rss_option ) {
|
||||
$size = 'thumbnail';
|
||||
$align = 'left';
|
||||
$style = 'margin:0px 0px 20px 20px;';
|
||||
$class = 'rss-small';
|
||||
}
|
||||
|
||||
$image = get_the_post_thumbnail( get_the_ID(), $size, array( 'align' => $align, 'style' => $style, 'class' => $class ) );
|
||||
|
||||
$content = $image . $content;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user