diff options
| author | 2018-06-12 12:35:52 +0200 | |
|---|---|---|
| committer | 2018-06-12 12:35:52 +0200 | |
| commit | eb3cca60dd346aafc6dfd0c2d25dcd7ce481fdf2 (patch) | |
| tree | 8214a8b0d1ed2af033979a896536016f1dad4e52 /app/Models/Feed.php | |
| parent | da025ed35650ba49b9aede5e92c33ea9118a6a69 (diff) | |
Fix get_thumbnails null exception (#1933)
Diffstat (limited to 'app/Models/Feed.php')
| -rw-r--r-- | app/Models/Feed.php | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php index cc2196dac..89eb0a53c 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -356,49 +356,53 @@ class FreshRSS_Feed extends Minz_Model { $content = html_only_entity_decode($item->get_content()); - $elinks = array(); - foreach ($item->get_enclosures() as $enclosure) { - $elink = $enclosure->get_link(); - if ($elink != '' && empty($elinks[$elink])) { - $content .= '<div class="enclosure">'; - - if ($enclosure->get_title() != '') { - $content .= '<p class="enclosure-title">' . $enclosure->get_title() . '</p>'; - } + if ($item->get_enclosures() != null) { + $elinks = array(); + foreach ($item->get_enclosures() as $enclosure) { + $elink = $enclosure->get_link(); + if ($elink != '' && empty($elinks[$elink])) { + $content .= '<div class="enclosure">'; + + if ($enclosure->get_title() != '') { + $content .= '<p class="enclosure-title">' . $enclosure->get_title() . '</p>'; + } - $enclosureContent = ''; - $elinks[$elink] = true; - $mime = strtolower($enclosure->get_type()); - $medium = strtolower($enclosure->get_medium()); - if ($medium === 'image' || strpos($mime, 'image/') === 0) { - $enclosureContent .= '<p class="enclosure-content"><img src="' . $elink . '" alt="" /></p>'; - } elseif ($medium === 'audio' || strpos($mime, 'audio/') === 0) { - $enclosureContent .= '<p class="enclosure-content"><audio preload="none" src="' . $elink - . '" controls="controls"></audio> <a download="" href="' . $elink . '">💾</a></p>'; - } elseif ($medium === 'video' || strpos($mime, 'video/') === 0) { - $enclosureContent .= '<p class="enclosure-content"><video preload="none" src="' . $elink - . '" controls="controls"></video> <a download="" href="' . $elink . '">💾</a></p>'; - } elseif ($medium != '' || strpos($mime, 'application/') === 0 || strpos($mime, 'text/') === 0) { - $enclosureContent .= '<p class="enclosure-content"><a download="" href="' . $elink . '">💾</a></p>'; - } else { - unset($elinks[$elink]); - } + $enclosureContent = ''; + $elinks[$elink] = true; + $mime = strtolower($enclosure->get_type()); + $medium = strtolower($enclosure->get_medium()); + if ($medium === 'image' || strpos($mime, 'image/') === 0) { + $enclosureContent .= '<p class="enclosure-content"><img src="' . $elink . '" alt="" /></p>'; + } elseif ($medium === 'audio' || strpos($mime, 'audio/') === 0) { + $enclosureContent .= '<p class="enclosure-content"><audio preload="none" src="' . $elink + . '" controls="controls"></audio> <a download="" href="' . $elink . '">💾</a></p>'; + } elseif ($medium === 'video' || strpos($mime, 'video/') === 0) { + $enclosureContent .= '<p class="enclosure-content"><video preload="none" src="' . $elink + . '" controls="controls"></video> <a download="" href="' . $elink . '">💾</a></p>'; + } elseif ($medium != '' || strpos($mime, 'application/') === 0 || strpos($mime, 'text/') === 0) { + $enclosureContent .= '<p class="enclosure-content"><a download="" href="' . $elink . '">💾</a></p>'; + } else { + unset($elinks[$elink]); + } - $thumbnailContent = ''; - foreach ($enclosure->get_thumbnails() as $thumbnail) { - if (empty($elinks[$thumbnail])) { - $elinks[$thumbnail] = true; - $thumbnailContent .= '<p><img class="enclosure-thumbnail" src="' . $thumbnail . '" alt="" /></p>'; + $thumbnailContent = ''; + if ($enclosure->get_thumbnails() != null) { + foreach ($enclosure->get_thumbnails() as $thumbnail) { + if (empty($elinks[$thumbnail])) { + $elinks[$thumbnail] = true; + $thumbnailContent .= '<p><img class="enclosure-thumbnail" src="' . $thumbnail . '" alt="" /></p>'; + } + } } - } - $content .= $thumbnailContent; - $content .= $enclosureContent; + $content .= $thumbnailContent; + $content .= $enclosureContent; - if ($enclosure->get_description() != '') { - $content .= '<pre class="enclosure-description">' . $enclosure->get_description() . '</pre>'; + if ($enclosure->get_description() != '') { + $content .= '<pre class="enclosure-description">' . $enclosure->get_description() . '</pre>'; + } + $content .= "</div>\n"; } - $content .= "</div>\n"; } } |
