• I’m creating a new WordPress 2 theme (for now I call it “newspaper”… the idea is to create a New York Times style look using a WordPress backend ) http://www.documentedlife.com. But for now I’m just working on creating a nice personal page.

    The archive pages are a mess! Pay them no attention. They will get better. I’m still hacking them.

    Just on the front page, my question is, how do I insert an image from an RSS feed from my other web site ( http://www.portlandground.com ) into the front page box of my documentedlife.com site?

    I’m new to PHP things, but I’m game to try anything, read anything, figure anything out.

    Each day portlandground has one new image, and I want that image (resized to fit a 220×220 pix box) on the front page of my personal site. The resizing is secondary however. The basic question is what functions do I use?

    Where is this described? I’ve searched a lot.

    I see that magpie RSS exists in a subfolder called AdditionsExtensions/Magpierss (v. .72). I understand that I need that, but do I have to do anything to magpie to use it?

    Is there an article somewhere that describes how to use an rss feed to grab an image from a site and insert the image?

    Since I own both sites, are there any considerations flowing from that for how to set this up?

    thanks!

    postscript:

    I do see this: http://codex.wordpress.org/Function_Reference/fetch_rss

    but, if this is the right function, how do I select just the image URL, and make it part of the page? Is that too obvious?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Okay, how you do this really depends on what you want to do.

    From your description, it sounds like you want to pull the RSS feed from http://www.portlandground.com/index.xml , get the latest image, resize it, then display it in a box. This is a bit tricky, but still doable. I’ll tell you how to do the RSS bits, but the image work is up to you.


    <?php
    require_once(ABSPATH . WPINC . '/rss-functions.php');
    // this bit gets your rss feed. Fill it in with the right feed info
    $rss = fetch_rss('http://example.com/rss/feed/goes/here');
    $item = $rss->items[0];
    if (preg_match("/<img.*src=\"?(.+?)\"?/i", $item['description'], $matches))
    {
    $matches[0] should now contain the url of the image.
    I may have futzed up the regular expression though.
    i think you want to get the image, resize it,
    save it somewhere locally and spit out your own
    img src=yourimage.jpg here,
    possibly along with a link to the full image
    if you do this, you may want to add a check here
    so as not to get the image and resize it
    more than once per day
    ...
    or if you don't want to do that, you can just
    spit out the img here with proper size attribs
    (deep linking)..
    downside is that your viewers are downloading the whole
    image, all 250k+ of it.
    }
    ?>

    Thread Starter miles

    (@miles)

    That’s exactly what I’d like to do. Thanks very much. I’ll give it a try, and post back here when it works.

    Thank you! (and I’ll bet your explanation will be valued by lots of people.)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to insert daily image from RSS feed into page? with resize?’ is closed to new replies.