| ... | ... |
@@ -61,6 +61,9 @@ img {
|
| 61 | 61 |
margin-left: 30%; |
| 62 | 62 |
margin-right: auto; |
| 63 | 63 |
} |
| 64 |
+#img-guardian {
|
|
| 65 |
+ width: 250px; |
|
| 66 |
+} |
|
| 64 | 67 |
#img-list-nyt {
|
| 65 | 68 |
width: 200px; |
| 66 | 69 |
height: 200px; |
| ... | ... |
@@ -2,6 +2,9 @@ |
| 2 | 2 |
include_once( 'news-constants.php' ); |
| 3 | 3 |
|
| 4 | 4 |
$rss_content = file_get_contents(NEWS_RSS_BBC); |
| 5 |
+$orgStrings = array( 'media:thumbnail'); |
|
| 6 |
+$newStrings = array( 'mediacontent'); |
|
| 7 |
+$rss_content = str_replace($orgStrings, $newStrings, $rss_content); |
|
| 5 | 8 |
$xml = simplexml_load_string($rss_content); |
| 6 | 9 |
if ($xml === false) {
|
| 7 | 10 |
echo 'Failed to read RSS'; |
| ... | ... |
@@ -21,8 +24,10 @@ if ($xml === false) {
|
| 21 | 24 |
$article['pubDate'] = $item->pubDate; |
| 22 | 25 |
$article['timestamp'] = strtotime($item->pubDate); |
| 23 | 26 |
$article['description'] = $item->description; |
| 27 |
+ $article['image'] = $item->mediacontent['url']; |
|
| 24 | 28 |
$articles[$cpt] = $article; |
| 25 | 29 |
echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
|
| 30 |
+ echo '<img id="img-list" src="'.$article['image'].'" style="display:block;"><br>'; |
|
| 26 | 31 |
echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '; |
| 27 | 32 |
echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div> '; |
| 28 | 33 |
echo $article['title'].' '; |
| ... | ... |
@@ -2,7 +2,7 @@ |
| 2 | 2 |
include_once( 'news-constants.php' ); |
| 3 | 3 |
|
| 4 | 4 |
$rss_content = file_get_contents(NEWS_RSS_CNA); |
| 5 |
-$orgStrings = array( 'media:content'); |
|
| 5 |
+$orgStrings = array( 'media:thumbnail'); |
|
| 6 | 6 |
$newStrings = array( 'mediacontent'); |
| 7 | 7 |
$rss_content = str_replace($orgStrings, $newStrings, $rss_content); |
| 8 | 8 |
$xml = simplexml_load_string($rss_content); |
| ... | ... |
@@ -24,8 +24,10 @@ if ($xml === false) {
|
| 24 | 24 |
$article['pubDate'] = $item->pubDate; |
| 25 | 25 |
$article['timestamp'] = strtotime($item->pubDate); |
| 26 | 26 |
$article['description'] = $item->description; |
| 27 |
+ $article['image'] = $item->mediacontent['url']; |
|
| 27 | 28 |
$articles[$cpt] = $article; |
| 28 | 29 |
echo '<div onclick="onArticle('.$cpt.')" style="display:inline;">';
|
| 30 |
+ echo '<img id="img-list" src="'.$article['image'].'" style="display:block;"><br>'; |
|
| 29 | 31 |
echo '<div id="nav-up" style="display:inline;"><a href="#top"><i class="fa fa-home fa-2x"></i></a></div> '; |
| 30 | 32 |
echo '<div id="nav-up" style="display:inline;"><a href="#article-top"><i class="fa fa-chevron-down fa-2x"></i></a></div> '; |
| 31 | 33 |
echo $article['title'].' '; |
| ... | ... |
@@ -73,7 +75,8 @@ foreach ($articles as $article ) {
|
| 73 | 75 |
//Extract image |
| 74 | 76 |
$re = '/<link rel="image_src" href="(.+?)"\/>/'; |
| 75 | 77 |
preg_match($re, $article_content, $matches); |
| 76 |
- $imageurl = $matches[1]; |
|
| 78 |
+ if(isset($matches[1])) |
|
| 79 |
+ $imageurl = $matches[1]; |
|
| 77 | 80 |
|
| 78 | 81 |
//Clean some sections |
| 79 | 82 |
//$article_only = re_remove($article_only, '//'); |