WordPress.org

Ready to get started?Download WordPress

Forums

First image from post - ENHANCED! (1 post)

  1. Josh Maxwell
    Member
    Posted 1 year ago #

    First off, I didn't come up with this code. I worked long and hard on something very different, got stuck, went looking, found this and scrapped what I had.

    This function will get the first image from a post, in this order:

    1. Featured image
    2. First image attached to post
    3. First image URL in the content of the post
    4. YouTube screenshot
    5. My contribution:

    6. Default images for different categories [SET MANUALLY]
    7. Backup-default image if all else fails [SET MANUALLY]

    A big THANKS goes out to Michelle on WordPress.StackExchange.com for her answer to a question that made this possible!!!

    Code and explanation can be found on PasteBin:
    PasteBin: Image from Post (Featured, Attached, 1st Image, YouTube, Category Defaults, Backup-Default)

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 1 year ago by Josh Maxwell
  • This topic is not a support question
  • WordPress version: 3.4.1