Adding Default Thumbnail Image in Google Blogger

As a blogger, you want your website to look professional and visually appealing. One way to achieve this is by adding default thumbnail images to your articles. By doing this, you can ensure that your articles have a consistent look and feel, even if there isn't an image available.

Google Blogger is a popular platform for bloggers to create their websites and blogs. By default, Google Blogger does not provide an option to add default thumbnail images to your articles. However, you can add this functionality by using a simple Javascript code.

You can use the following Javascript code to check if an article has an image or not. If there is no image, then you can add a default thumbnail image.

function addDefaultThumbnail() {
  var posts = document.querySelectorAll('.post');
  for (var i = 0; i < posts.length; i++) {
    var post = posts[i];
    var postImage = post.querySelector('.post-body img');
    var defaultImage = 'default-thumbnail.jpg';
    if (!postImage) {
      post.innerHTML += `<img src="${defaultImage}" alt="Default Thumbnail Image">`;
    }
  }
}

In the above code, we are selecting all the posts using the querySelectorAll method. Then, we are iterating over each post and checking if there is an image element inside the post using querySelector. If there is no image, we are adding a new image element with the source set to the default thumbnail image.

You can replace default-thumbnail.jpg with the path to your own default thumbnail image. This code is customizable and you can modify it to suit your needs.

To use this code in your Google Blogger, follow these steps:

  1. Go to your Google Blogger dashboard
  2. Click on "Theme"
  3. Click on "Edit HTML"
  4. Scroll down to the end of the file and paste the above code just above the </body> tag
  5. Click on "Save theme"

By following these steps, the Javascript code will be added to your Google Blogger website or blog. This will enable the functionality to add default thumbnail images to your articles.

In conclusion, adding default thumbnail images to your articles is an easy way to make your website or blog look more professional and visually appealing. By using the Javascript code above, you can easily add this functionality to your Google Blogger website or blog.

I hope this helps you. Let me know if you have any questions.

댓글 쓰기

0 댓글