Product image did not render when sharing link of product on Twitter first time - twitter

The product share on Twitter for the first time not render the product image.
I have set the <meta> tag with og:image value.
But twitter not show this image first time.
I have code below meta tags.
<meta name="twitter:card" content='summary_large_image'>
<meta property="og:image" content="https://www.example.org/image.jpg">
<meta property="og:image:width" content="200" />
<meta property="og:image:height" content="200" />

Try adding something like this:
<meta name="twitter:image" content="http://euro-travel-example.com/thumbnail.jpg">
More details here: https://css-tricks.com/essential-meta-tags-social-media/
Also, you can use this to preview your twitter card: https://www.bannerbear.com/tools/twitter-card-preview-tool/

Related

Twitter is not showing thumbnail for my page

I am trying to add a thumbnail when a user shares a page of my site. According to the documentation, it is necessary to define some parameters for the card i.e. image, title, description, etc. I am using the snippet on the page, however, when I share the card, my image does not show up.
This is my current <head>
<!-- Twitter open-graph tags -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="#twitter_user">
<meta name="twitter:site" content="#twitter_user">
<meta name="twitter:image:alt" content="Site name">
<meta name="twitter:image" content="https://examplesite.com/static/landing/img/img.png" />
<meta name="twitter:title" content="{% trans 'Site Title' %} - Site" />
<meta name="twitter:description" content="{% trans 'Site description' %}" />
<meta name="twitter:url" content="https://www.examplesite.com{% url path %}">
I am using the absolute path, i.e.: https://examplesite.com/img/img.png (adding my domain to load the image), also using the HTTPS protocol, with an image in PNG format of 80kb and 1200x630px.
When I want to validate my site with this tool, I get this result, in which the image is not visible and also, according to the log, not all the defined parameters are detected.

Twitter summary card with large image not working

<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="#nytimes">
<meta name="twitter:creator" content="#SarahMaslinNir">
<meta name="twitter:title" content="Parade of Fans for Houston’s Funeral">
<meta name="twitter:description" content="NEWARK - Thenter code heree guest list and parade of limousines with celebrities emerging from them seemed more suited ">
<meta name="twitter:image" content="http://graphics8.nytimes.com/images/2012/02/19/us/19whitney-span/19whitney-span-articleLarge.jpg">
I have used all the above meta tags, but still the image appears only as a summary card rather than displaying a summary card with large image.
I've been testing your code on a test page, html only. Everything worked fine for me. Here is also the Tweet generated with only the meta tags inside.
Looks to me more, there are other problems inside the html that might cause wrong interpretation of your meta tags.

Sharing to Twitter and LinkedIn with images and descriptions

I need to share images from web links with text to Twitter and LinkedIn.
I am able to add text, but I am not able to add images.
I am using Kentico CMS and I have written the web part transformation as below. But the image is not shown on the Twitter and LinkedIn plugins.
Attached here with the transformation below.
Added the Twitter and LinkedIn result without images.
Can any one guide me with sharing to Twitter and LinkedIn feeds with images?
Thanks
<a class="fb-xfbml-parse-ignore" target="_blank"
href="https://twitter.com/intent/tweet?url=<%=Server.UrlEncode(CMS.DocumentEngine.DocumentContext.CurrentDocument.AbsoluteURL)%>
&picture=<%#GetAbsoluteUrl(CMS.DocumentEngine.DocumentContext.CurrentDocument.GetValue("StoryImageURL").ToString())%>
&text=<%#CMS.DocumentEngine.DocumentContext.CurrentDocument.GetValue("Title").ToString()%>"
onClick="return popup(this, 'notes')">
<img src="<%# Eval("twittericon") %>" alt="twitter icon" />
</a>
<a class="fb-xfbml-parse-ignore" target="_blank" href="https://www.linkedin.com/shareArticle?url=<%=CMS.DocumentEngine.DocumentContext.CurrentDocument.AbsoluteURL%>
&picture=<%#GetAbsoluteUrl(CMS.DocumentEngine.DocumentContext.CurrentDocument.GetValue("StoryImageURL").ToString()) %> <%#CMS.DocumentEngine.DocumentContext.CurrentDocument.GetValue("BlogDescription").ToString()%>" onClick="return popup(this, 'notes')">
<img src="<%# Eval("linkedicon") %>" alt="linked icon" />
</a>
First of all, I do not think Twitter and LinkedIn expose a way of sharing an image alongside the text just by adding a parameter to the share URL.
For Twitter, you could set up Cards, such as a Summary Card, and add meta tags to your website. By adding a twitter:image meta tag, you can tell Twitter which image to use.
Similar applies to LinkedIn - you would need to use Open Graph meta tags, as there is no way to provide an image as part of the share URL.
Regarding the transformation you wrote - make sure you are rendering the correct data, as using CMS.DocumentEngine.DocumentContext.CurrentDocument inside a transformation would retrieve data from the current document that is being viewed, as opposed to data of the repeated item. For rendering data of the repeated item, you can use the Eval method.
This:
<%#CMS.DocumentEngine.DocumentContext.CurrentDocument.GetValue("Title").ToString()%>
Would become this:
<%#Eval("Title")%>
For all my sites I use a Head HTML Code webpart on the page template of the pages I want or need to have this Open Graph (OG) data on. Here's a sample of what I put in it to dynamically populate some of the data.
<meta property="og:site_name" content="Kehren Development - Kentico MVP & Experts" />
<meta property="og:url" content="{% CurrentDocument.AbsoluteURL #%}" />
<meta property="og:image" content="{%RootDocument.AbsoluteURL#%}KehrenDev/media/images/logos/twitter-logo-800.jpg" />
<meta property="og:type" content="article" />
<meta property="og:title" content="{% BlogPostTitle %}" />
<meta property="og:description" content="{% StripTags(BlogPostSummary) %}" />
<meta property="article:publisher" content="https://www.facebook.com/bkehren" />
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="{% BlogPostTitle %}">
<meta name="twitter:site" content="#kehrendev">
<meta name="twitter:creator" content="#bkehren">
<meta name="twitter:description" content="{% StripTags(BlogPostSummary) %}">
<meta name="twitter:url" content="{% CurrentDocument.AbsoluteURL #%}">
<meta name="twitter:image" content="{%RootDocument.AbsoluteURL#%}KehrenDev/media/images/logos/twitter-logo-800.jpg">
<meta name="twitter:domain" content="{%RootDocument.AbsoluteURL#%}">
This will be rendered on the page anytime a blog post is viewed. You can set these properties on the webpart to only display for those page types. There are other meta tags you can use or different fields you can set but this will get you started.
Now you can still use the share links you have but only populate the share link with the actual article link and maybe an encoded description, the OG tags will pickup the rest.

Small preview when sharing link on Social media Ruby On Rails

I'm working on a site whose front end is in angularjs and backend in ROR , Same ROR API is used in an android app also . Now I have a situation here . I need to share my Web's post on the Social media like facebook , twitter and google plus . And along with the link to the single post there should be a small preview also (a preview of the post which crawls before posting e.g in facebook) .I did it using angular Plugins . But when it comes to Android side , what they share and what displays on Facebook is the Link only . Then i did some R&D and i came to know that it must be done on server side with social media meta tags . I did a little bit but it still no works . I'm stuck on it . Below is what i've done so far .
def show
#post = Post.find_by_permalink(params[:id])
respond_to do |format|
format.html
format.js
end
end
In My views posts/show.html.erb
<!DOCTYPE html>
<html>
<head>
<title> Shared Question</title>
<meta property="og:title" content="My Page" />
<meta property="og:description" content="A description of my page." />
<meta property="og:image" content="http://www.example.com/images/my_lovely_face.jpg" />
<!-- etc. -->
</head>
<body>
Here is the body
</body>
</html>
I just need to show a small preview whenever some user share my web post's link on any media
You are correct, you need to implement special open graph (and other) tags for the customized social sharing functionalities.
Keep in mind that e.g. facebook will cache your page.
So you may try https://developers.facebook.com/tools/debug/ to test your code without caching - the code itself looks fine.
Example Code:
Place this code between <head> and </head> with your other meta tags.
<meta property="og:title" content="Title">
<meta property="og:site_name" content="Name">
<meta property="og:url" content="URL">
<meta property="og:description" content="Description Text">
<meta property="og:type" content="article">
<!--- network Specific -->
<meta property="fb:app_id" content="AppID">
<meta name="twitter:card" content="app">
<meta name="twitter:site" content="#FernerJohannes">
If you want to target Twitter specifically here are their card-guidelines:
https://dev.twitter.com/cards/getting-started
You may also want to checkout: Open Graph validation for HTML5
You can set a custom image for you website to be shown in fb posts -
Add the OG XML to your html tag
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://ogp.me/ns/fb#">
Add these meta tags to set the custom image that OG will use
<meta property="og:image" content="url_to_image" />
You can try reading this for more insight.
Hopefully this helps.

Twitter Product Card - Multiple Pages

I have a product which has 3 pages:
http://www.example.com/myproduct
http://www.example.com/myproduct/more
http://www.example.com/myproduct/images
I want to add a product twitter card:
<meta name="twitter:card" content="card">
<meta name="twitter:site" content="#mytwitter">
<meta name="twitter:title" content="My Product Title">
<meta name="twitter:description" content="Product Description goes here...">
<meta name="twitter:url" content="http://www.example.com/myproduct">
<meta name="twitter:image" content="http://www.example.com/product.jpg">
<meta name="twitter:data1" content="$3">
<meta name="twitter:label1" content="PRICE">
<meta name="twitter:data2" content="San Franscisco, CA">
<meta name="twitter:label2" content="LOCATION">
What I want to achieve is that the product image, description, price, and location should be shown from all 3 pages when the user shares any of the pages.
My questions is how can I achieve this, and is it better to use <meta name="twitter:url" content="http://www.example.com/myproduct"> for all 3 pages, or use the canonical url of each page.
In order to display the same Product Card for any of the three pages of your product, all you have to do is simply making sure you provide the same markup tags on all of them.
In fact, you don't even have to specify any twitter:url tag in Twitter Cards. The URL the user will be redirected to when clicking is automatically the one that has been shared in the Tweet.

Resources