Ready to get started?Download WordPress


[resolved] the_post_format_image renders full post for standard posts (8 posts)

  1. Bev
    Posted 1 year ago #

    I decided to try using the_post_format_image to grab the first image associated with a post and display it with the excerpt. However, if the post is a standard format it does not grab the first image - the entire post is displayed!

    I'm not sure if I'm using the function as it was intended, but the description in media.php reads:

    "Return the first image in the current (@global) post's content"

    so I would expect only the first image found in the post to be rendered.

  2. I think that function is only for Image post format, not Standard or any else formats.

  3. Chip Bennett
    Theme Review Admin
    Posted 1 year ago #

  4. designsimply
    Posted 1 year ago #

    However, if the post is a standard format it does not grab the first image - the entire post is displayed!

    Is the problem happening for just one post or several?

    I'm not sure it's post format related. As a test, try temporarily replacing the post content for the affected post(s) with a simple plain text paragraph (no links or images), then clear cache and refresh the page where the_post_format_image() is called.

    My theory is that something in the content is triggering the regex in that function when it shouldn't.

  5. Post Formats UI has been removed from 3.6

    When Beta4 comes out, please test this again.

  6. Bev
    Posted 1 year ago #

    Okay, I did some more testing with 3.6-beta4-24523.

    I'm using the "Images Test" post from the standard theme test posts. For this post the_post_format_image will not return not the first image. Instead it skips along to the first captioned image (the boat with caption "A picture is worth a thousand words") and returns that image and all of the following post content.

    Also I noticed if a post has a featured image that is not attached to the post, it will not be displayed.

  7. Bev
    Posted 1 year ago #

    i just did some further testing. It seems that the image links on the boat pictures are causing the problems. If I remove the links the first image is selected properly.

  8. The function the_post_format_image is gone.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.