php - Can SimplePie grab images from feeds -
i using simplepie , have uploaded files host. seems working fine except 1 thing. blog i'm getting feed has images in it, , when use simplepie view feed, images don't show up. there way images show when view blog simplepie?
okay sorry, new @ this. using code straight website try , view blog. put code @ bottom here. yea said i'm trying images show on blog i'm reading from. shows great except that.
--- header information ---
<?php // make sure simplepie included. may need change match location of simplepie.inc. require_once('simplepie.inc'); // we'll process feed of default options. $feed = new simplepie(); // set feed process. $feed->set_feed_url('http://wordpress.homickdesign.com/feed/'); // run simplepie. $feed->init(); // makes sure content sent browser text/html , utf-8 character set (since didn't change it). $feed->handle_content_type(); // let's begin our xhtml webpage code. doctype supposed first thing, we'll keep on same line closing-php tag. ?>
--- code ---
<h2><a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_description(); ?></a><br /> <span>latest news robert homick</span></h2> <?php $c=1; foreach ($feed->get_items() $item): if($c <= 3){ ?> <p><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a><br /> <?php echo $item->get_description(); ?><br /> <span>posted on <?php echo $item->get_date('j f y | g:i a'); ?></span><br /> <?php $c++;?> <?php } endforeach; ?>
yes, can call get_content() , entire post or portion of post included in feed outputted screen, html tags included. if want pull first image in post, have little more work, here i've been doing.
$htmldom = new simple_html_dom(); $htmldom->load($item->get_content()); $image = $htmldom->find('img', 0); $html .= '<img src="thumbnail.php?file=' . $image->src . '&maxw=300&maxh=300" border="0" />';
that snippet current little project, uses simple_html_dom , script got off internet resize images on fly. if want display image not resize @ $image->src url. think functionality may added simplepie in future or add-on simplepie, in mean time, 4 lines of code display first image item feed.
Comments
Post a Comment