WordPress.org

Ready to get started?Download WordPress

Forums

RSS Just Better
Add Images to the plugin (5 posts)

  1. josephcmiller2
    Member
    Posted 1 year ago #

    OK, I have added image support to the plugin for an image in an enclosure.

    Here is the relevant code:

    // test get the enclosure
    if ( $enclosure = $item->get_enclosure(0) ) {
      $enclosure_link = $enclosure->get_link();
      if ( preg_match("/\.(png|jpg|gif)$/", $enclosure_link) ) {
        $flist .= "<img src='".$enclosure_link."' />";
      }
    }

    And you just add it before this existing code

    // writes the link
    $flist .= "<a target='$target' href='$permalink'";
    ...

    And you'll get your image. Use CSS styling to format it.

    I use WP RSS Images plugin to add images to the WordPress feed in the first place. Here is an example of this plugin working on my site to show the recent articles with an image.

    http://www.articlespawn.net/

    http://wordpress.org/extend/plugins/rss-just-better/

  2. josephcmiller2
    Member
    Posted 1 year ago #

    Here's a better version:

    // display the first enclosure image
    if ( $enclosure = $item->get_enclosure(0) ) {
      if ( preg_match("/^image\//", $enclosure->get_type()) ) {
        $flist .= "<a class='rssjbimg' target='$target' href='$permalink'";
        if (!filter_var($excerpt, FILTER_VALIDATE_BOOLEAN)) $flist .= " title='".substr($motext,0,400)."...'";
        $flist .= ">";
        $flist .= "<img src='".$enclosure->get_link()."' />";
        if ( $permalink ) $flist .= '</a>';
      }
    }
  3. Andres Felipe
    Member
    Posted 1 year ago #

    I'm always surprised by all the people out there whom already thougth something You was thinking. If this code takes the thumb from the imported articles for RSS and put it besides the excerpt, this is just what I was looking for. I'll try it and feedback.

  4. Andres Felipe
    Member
    Posted 1 year ago #

    Is not working, do I need to add something else in the shotcode or just paste the code You wrote in the file?

  5. josephcmiller2
    Member
    Posted 1 year ago #

    Andres, Try this feed. This is the one I got to work:

    http://www.articlespawn.net/feed/

    Let me know if it doesn't work.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic