PHP Code:
# the first error is happening because foreach{} expects an array (or iterable object).
# you need to make sure that's what you give it.
# the second error is happening because of the first error.
# try the method first
$enclosures = $item->get_enclosures();
# see if it worked
# (I'm assuming this get_enclosures method returns FALSE if it doesn't return an array.
# If that is not the case, you might need to use "if( is_array( $enclosures ) )" instead -
# more correct, more accurate; but, if it works, doing "if( $enclosures )" is faster.
if( $enclosures ){
// foreach($item->get_enclosures() as $enclosure);
# ALWAYS use brackets!
# pass $enclosures to foreach{}
foreach( $enclosures as $enclosure ){ //<-- important opening bracket
# likewise, you might want to check if ::get_link() is returning a string as you expect
$i['img'] = str_replace("_m.jpg","_s.jpg" , $enclosure->get_link());
}//<-- important closing bracket
} // end "if( $enclosures )"
if(empty($i['img'])){
$i['img'] = 'img/noimage.png';
}
Bookmarks