Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Exclude Jumbotron Image from Social Media Thumbnail?

Whenever my blog post is shared, the thumbnail is automatically the jumbotron image first instead of defaulting to the blog post image:

enter image description here

enter image description here

view

<%= image_tag "galli-walking.jpg", alt: "Conquering life and goal challenges so we can get the most out of life.", class: "main-image" %>
<div class="blog-text">
  <div class="blog-paragraph">
    A DAILY BLOG ABOUT MY<br>
    JOURNEY & LIFESTYLE
  </div>
  <%= render 'subscribes/subscribe.html.erb' %>
</div>
<%= link_to @post.title, blog_path(@post) %>
<%= simple_format(@post.body, {}, {:sanitize => false}) %>
like image 420
AnthonyGalli.com Avatar asked Mar 11 '23 17:03

AnthonyGalli.com


2 Answers

Try to add this tag to <head></head>

<meta property="og:image" content="<%= image_path('your_image') %>" />

Possible solution to exclude image from using by share is to use div with CSS background-image property. Instead

<%= image_tag "galli-walking.jpg", alt: "Conquering life and goal challenges so we can get the most out of life.", class: "main-image" %>

use

<div style="background-image: url('galli-walking.jpg'); width:Xpx; height:Xpx;></div>
like image 172
Michael Malov Avatar answered Mar 25 '23 00:03

Michael Malov


Read more from these articles. All you need is to dynamically generate Facebook Open Graph meta tag like so.

<meta property="og:image" content="http://static01.nyt.com/images/2015/02/19/arts/international/19iht-btnumbers19A/19iht-btnumbers19A-facebookJumbo-v2.jpg" />

https://blog.kissmetrics.com/open-graph-meta-tags/

https://developers.facebook.com/docs/sharing/webmasters

Generating Facebook Open Graph meta tags dynamically

like image 30
trungk18 Avatar answered Mar 24 '23 22:03

trungk18