• Hey guys

    I just updated WP to 3.5 and noticed, that my script for adding the post image to the rss feed doesn’t work anymore. There’s no error, just no Picture in the feed. Here is my code, which worked fine until now:

    function my_feed_thumbnail($content) {
    if (is_feed() && has_post_thumbnail()) {
    return the_post_thumbnail( ‘single-post-thumbnail’ ) . $content;
    }
    return $content;
    }
    add_filter(‘the_content’, ‘my_feed_thumbnail’);

    Were there changes to the API?

Viewing 7 replies - 1 through 7 (of 7 total)
  • This problem is related to insert image in post content. Doesn’t work anymore.

    Since you’re using the return of the function, you should really do get_the_post_thumbnail() — not the_post_thumbnail() — the latter just echoes the image to the screen, while the former is meant to give you the image tag in a string.

    Thread Starter rancor2k

    (@rancor2k)

    any idea on how to fix this?

    Also — get_the_post_thumbnail would require the first argument passed to it to be either the post_id (gettable via get_the_ID()) or null — the second arg is the image size. Make sure to bump it back.

    My problem is not get the picture in post list or open post, but insert image in post content.

    The picture uploaded, but not insert in post content.

    Sorry my english is not very good. ??

    Thread Starter rancor2k

    (@rancor2k)

    That did the trick, thanks a lot! Here’s my updated code, if anyone is interested:

    function my_feed_thumbnail($content) {
        if (is_feed() && has_post_thumbnail()) {
            return get_the_post_thumbnail( get_the_ID(), 'medium' ) . $content;
        }
        return $content;
    }
    add_filter('the_content', 'my_feed_thumbnail');

    My problem is compatibility with plugin https://www.ads-software.com/extend/plugins/custom-field-template/

    witchcraft!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Post image not shown in feed since 3.5’ is closed to new replies.