SimplePie::set_image_handler PHP Method

set_image_handler() public method

Set the handler to enable the display of cached images.
public set_image_handler ( str $page = false, str $qs = 'i' )
$page str Web-accessible path to the handler_image.php file.
$qs str The query string that the value should be passed to.
    public function set_image_handler($page = false, $qs = 'i')
    {
        if ($page !== false) {
            $this->sanitize->set_image_handler($page . '?' . $qs . '=');
        } else {
            $this->image_handler = '';
        }
    }

Usage Example

Example #1
0
    // Use the URL that was passed to the page in SimplePie
    $feed->set_feed_url($_GET['feed']);
    // XML dump
    $feed->enable_xml_dump(isset($_GET['xmldump']) ? true : false);
}
// Allow us to change the input encoding from the URL string if we want to. (optional)
if (!empty($_GET['input'])) {
    $feed->set_input_encoding($_GET['input']);
}
// Allow us to choose to not re-order the items by date. (optional)
if (!empty($_GET['orderbydate']) && $_GET['orderbydate'] == 'false') {
    $feed->enable_order_by_date(false);
}
// Allow us to cache images in feeds.  This will also bypass any hotlink blocking put in place by the website.
if (!empty($_GET['image']) && $_GET['image'] == 'true') {
    $feed->set_image_handler('./handler_image.php');
}
// We'll enable the discovering and caching of favicons.
$feed->set_favicon_handler('./handler_image.php');
// Initialize the whole SimplePie object.  Read the feed, process it, parse it, cache it, and
// all that other good stuff.  The feed's information will not be available to SimplePie before
// this is called.
$success = $feed->init();
// We'll make sure that the right content type and character encoding gets set automatically.
// This function will grab the proper character encoding, as well as set the content type to text/html.
$feed->handle_content_type();
// When we end our PHP block, we want to make sure our DOCTYPE is on the top line to make
// sure that the browser snaps into Standards Mode.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
All Usage Examples Of SimplePie::set_image_handler