How to Fix Uncaught ReferenceError: thumbnail is not defined - with below code

How to Fix Uncaught ReferenceError: thumbnail is not defined - with below code

我在我的网站上安装了这个博主最近的 post 代码 JavaScript。有时这段代码不起作用,当我用 google chrome 开发工具检查时,我收到这样的错误:Uncaught ReferenceError: thumbnail is not defined -使用以下代码。

下面我附上了Javascript、Css和HTMl代码。我需要有关此 JavaScript 函数的帮助。

.mbtlist {
      list-style-type: none;
      overflow: hidden
    }
    .mbtlist li {
      margin: 0px auto 20px auto;
      clear: both;
      color: #666;
      font-family: Helvetica;
      font-size: 12px;
      border-bottom: 1px dotted #ddd;
      padding-bottom: 10px;
      overflow: auto;
    }
    .mbtlist .mbttitle {
      font-family: oswald;
      font-size: 16px;
      color: #0080ff;
      font-weight: normal;
      text-decoration: none;
    }
    .mbtlist .mbttitle:hover {
      color: #00A5FF;
    }
    font-family:georgia;
    font-size:15px;
    font-weight:bold
    }
    .mbtlist div span {
      margin: 0 10px 0 0;
      display: inline-block;
    }
    .mbtlist span {
      display: block;
      margin: 5px 0px 0px;
      padding-right: 5px;
    }
    .mbtlist .imore {
      font-size: 16px;
      font-weight: bold;
      text-decoration: none;
      color: #666;
      line-height: 0.7em;
    }
    .mbtlist img {
      float: left;
      margin: 0px 10px 10px 0px;
      border: 6px solid #fff;
      padding: 0px;
      width: 80px;
      height: 65px;
      box-shadow: -1px -1px 4px #777;
    }
    .mbtlist .icontent {
      text-align: justify;
    }
<script>
function getPosts(json) {
  var posts = "<ul class=mbtlist>";
  for (var i = 0; i < json.feed.entry.length; i++) {
    var title = json.feed.entry[i].title.$t;
    var url = json.feed.entry[i].link.pop().href;
    if (json.feed.entry[i].media$thumbnail){
      thumbUrl = json.feed.entry[i].media$thumbnail.url;
      thumbnail= thumbUrl.replace("/s72-c/","/s"+80+"/");
    }
    posts += "<li><a class='mbttitle' href='" + url + "'><img src='" + thumbnail + "'>" + title + "</a></li>";
  }  
  posts+='</ul>';
  document.getElementById('container').innerHTML = posts;
}
</script>

<div id="container"></div>
<script src="https://www.sebahotnews.org/feeds/posts/default/-/জাতীয়
?max-results=5&alt=json&callback=getPosts"></script>

发生这种情况是因为某些帖子没有图像或外部托管图像,我们可以使用这样的后备图像

for (var i = 0; i < json.feed.entry.length; i++) {
    var title = json.feed.entry[i].title.$t;
    var url = json.feed.entry[i].link.pop().href;

    // define thumbnail variable
    var thumbnail;

    if (json.feed.entry[i].media$thumbnail) {
        thumbUrl = json.feed.entry[i].media$thumbnail.url;
        thumbnail = thumbUrl.replace("/s72-c/", "/s" + 80 + "/");
    } else {
        // if post thumbnail not found use a fallback image
        thumbnail = "https://www.blogger.com/img/logo_blogger_40px.png"
    }

    posts += "<li><a class='mbttitle' href='" + url + "'><img src='" + thumbnail + "'>" + title + "</a></li>";
}