Jump to content

Ultrus, RSS Fetch subtract images from RSS parse...


brad45429

Recommended Posts

Ultrus,

 

Everything is working fine with your BEAUTIFUL php script that you wrote FOR ME. 

 

I came across a problem today though.  http://www.xenianaz.org/blogs/

 

One of my guys blogged today and posted a photo at the beginning of his blog post, and ONLY the image he posted shows up on my parsed, outputed feed.

 

Is there a way to modify the script to NOT include images?

 

Sorry man.  YOU ROCK!  Here is the script again if you need to see it....

 

<?php
define('MAGPIE_DIR', '../blogs/magpie/');
require_once(MAGPIE_DIR.'rss_fetch.inc');

$rss = fetch_rss('http://xenianaz.org/blogs/jim/atom.xml');
$item = $rss->items[0];

//this changed a bit. It's not $content anymore
$allContent = $item['atom_content'];

//first 200 characters, some word might be chopped off here
$content = substr($allContent, 0, 200);

//whatever is being hidden, with possible chopped in half word at beginning
$remainingContent = substr($allContent , 200, (strlen($allContent) - 200));

//might want to check if a space is the last character of the current content
//if so, no words were chopped in half
if(substr($content, (strlen($content) - 1), 1) == " ") { //this is where I made my mistake
     $remainingContent = false;
}

//if there were less than 200 characters to begin with, skip the following
if($remainingContent && strlen($remainingContent) > 0) {
     $spacePosition = stripos($remainingContent, " "); //position of next space/word break
     if($spacePosition)
          $content .= substr($remainingContent, 0, ($spacePosition + 0));
     } else {
          $content .= $remainingContent;
    }
echo "<p>$content...</p>\n";
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.