3

SimplePie is an open source RSS parser. Evidently, SimplePie can cache images from RSS feeds it processes. But I don't know what to make of the documentation.

The example code looks like this

$feed = new SimplePie();
$feed->set_feed_url('http://simplepie.org/blog/feed/');
$feed->set_image_handler('handler_image.php', 'image'); // handler_image.php?image=67d5fa9a87bad230fb03ea68b9f71090
$feed->init();
$feed->handle_content_type();
echo $feed->get_title();

But handler_image is not a file included with simple. However, after downloading various hacks and add-ons over time, I ended up with a file called handler_image.php. This is literally all the code included in the file -->

require_once('autoloader.php');
SimplePie_Misc::display_cached_file($_GET['i'], '../cache', 'spi');

It doesn't do anything.

I tried substituting handler_image.php with timthumb.php (which I have installed on my server) but that doesn't work either.

Any suggestions?

http://simplepie.org/wiki/reference/simplepie/set_image_handler

Richard
  • 209
  • 2
  • 10

1 Answers1

0

you want to do something like this in your 'handler_image.php' file:

$feed = new SimplePie();

$cache = $feed->registry->call('Cache', 'get_handler', array($feed->cache_location, $_GET['image'], 'spi'));

$image = $cache->load();

that will get you an array containing the image data, then you can serve it how you like.

mal
  • 62
  • 4