Forums

Add an image to rss feed. (1 post)

  1. supergab
    Member
    Posted 1 year ago #

    Hi I use the following function to add a thumbnail to the post in the rss feed.

    <?php
    function insertThumbnailRSS($content) {
    global $post;
    if ( has_post_thumbnail( $post->ID ) ){
    $content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
    }
    return $content;
    }
    add_filter('the_excerpt_rss', 'insertThumbnailRSS');
    add_filter('the_content_feed', 'insertThumbnailRSS');
    ?>

    But instead of only using the post_thumbnail that I have to set mannualy I would like the function to fallback to the first uploaded image of the post's gallery (thumbnail size).

    How can I do this ?

    Many thanks for your time and help.

Topic Closed

This topic has been closed to new replies.

About this Topic