HTML5 Snippets - Add A Thumbnail Image To Your Customized Tweets That Link To Your Articles Web Page Using The <meta> Element Cover Image

HTML5 Snippets - Add A Thumbnail Image To Your Customized Tweets That Link To Your Articles Web Page Using The <meta> Element

Published:

Rate Article (Sign in and be the first to rate this article.)

Article Details

Views: 559

First Published:

Word Count: 1534

Edition: 1

Lets say you want to add a thumbnail image to your customized tweets that use Twitter's Summary Card format. For example, if you have an image that is associated with an article that has been tweeted you can give the tweeted links reader a preview of the content of your article along with the articles image before the reader clicks through to your web page. You can learn more about Twitter's Summary Card in an earlier tutorial that was published called "HTML5 Snippets - Customize Tweets That Link To Your Articles Web Page Using The <meta> Element".

Now in-order to add a thumbnail image to your Twitter's Summary Card. You will need the <meta> element along with the name attribute and content attribute. You will then need to include the twitter:image value for the name attribute in-order to tell Twitter's web crawler to expect an image that will represent your web pages content. Next you will need to include the content attribute. The content attributes value should be the URL of the image to be displayed with your web pages content. Your image should have a minimum width of 120px and a minimum height of 120px. Images that are larger than the dimensions of 120px x 120px will be resized and cropped square based on the images longest dimension. Your image should also be less than 1MB in size. The image will be displayed as a thumbnail image in the upper right hand corner of the Summary Card.

Now that you know how to add a thumbnail image to your Twitter's Summary Card. You will now need to add the Summary Cards 4 required <meta> elements in-order for your Summary Card to work properly. The first required <meta> element will require the name attribute and content attribute. You will then need to add the twitter:card value for the name attribute in-order to tell Twitter's web crawler to expect a Twitter Card from your web page. Next you will need to add the content attribute. The content attribute should have the value of summary in-order to tell Twitter's web crawler that you would like to use Twitter's Summary Card format for your web pages content.

Our second required <meta> element will also need the name attribute and content attribute. You will then need to add the twitter:description value for the name attribute in-order to tell Twitter's web crawler to expect a description for your web pages content. Next you will need to add the content attribute. The content attributes value should be a description that describes your web pages content. You should never re-use the title text as the description for your web pages content. Twitter will shorten your description to about 200 characters.

Now for our third required <meta> element we will need the name attribute and content attribute as well. You will then need to add the twitter:title value for the name attribute in-order to tell Twitter's web crawler to expect a title for your web pages content. Next you will need to add the content attribute. The content attributes value should be a title describing your web pages content. Twitter will shorten your title to about 70 characters, so it's best to keep your title short and to the point when possible.

And for our fourth required <meta> element we will also need the name attribute and content attribute. You will then need to add the twitter:url value for the name attribute in-order to tell Twitter's web crawler to expect a URL to your web pages content. Next you will need to add the content attribute. The content attributes value should be the canonical URL of your web pages content. A canonical URL in layman's terms is the preferred URL you want your users or search engines to see for the link to your web pages content when you have multiple URLs that are all different pointing to the same web page.

It's important to remember that in-order for your Twitter's Summary Cards <meta> elements to work you must first apply for the Twitter Summary Card which is free. The process usually consists of you signing in to your Twitter account and then entering the URL of a web page from your web site containing the Summary Cards <meta> elements into the Validate & Apply text box. Once your web page has been validated, you can then request for the final approval for your Twitter's Summary Card. When requesting for the final approval for your Twitter's Summary Card you will have to provide some basic information about your web site and Twitter account. You then can expect a response within a few weeks or less, but you will usually hear a response within minutes by email when your request has been reviewed. Once approved you will then need to wait for Twitter's web crawler to re-index your web pages meta information in-order to see your Twitter Card in action, which should be about a week or so. Another important thing to remember is that if you want to use other kinds of Twitter Cards you will need to start the process over again of validating and requesting final approval for your Twitter Card each time. You can learn more about Twitter Cards at Twitter's developers web page for Twitter Cards.

Now let me first show you the code by itself for the HTML snippet for adding a thumbnail image to your customized tweets that link to your articles web page using the <meta> elements. And then I will show you how to code and where to place the HTML snippet for both HTML5 and XHTML5.

Here is the HTML code snippet below to add a thumbnail image to your customized tweets that link to your articles web page using the <meta> elements.


<meta name="twitter:card" content="summary" />
<meta name="twitter:image" content="http://www.example.com/a-link-to-an-image-representing-your-web-pages-content.jpg" />
<meta name="twitter:description" content="A description of your web pages content." />
<meta name="twitter:title" content="A title describing your web pages content" />
<meta name="twitter:url" content="http://www.example.com/the-preferred-link-to-your-web-pages-content.htm" />

Here is the HTML code snippet to add a thumbnail image to your customized tweets that link to your articles web page using the <meta> elements for HTML5 in the example below.


<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <title>Welcome To HTML5</title>
 <meta name="twitter:card" content="summary">  
 <meta name="twitter:image" content="http://www.example.com/some-image.jpg">  
 <meta name="twitter:description" content="Lets say you want to add a thumbnail image to your customized tweets that use Twitter's Summary Card format. For example, if you have an image that is associated with an article that has been tweeted you can give the tweeted links reader a preview of the content of your article along with the articles image before the reader clicks through to your web page.">  
 <meta name="twitter:title" content="HTML5 Snippets - Add A Thumbnail Image To Your Customized Tweets That Link To Your Articles Web Page Using The &lt;meta&gt; Element">  
 <meta name="twitter:url" content="http://www.example.com/twitter-summary-card-with-a-thumbnail-image.htm">  
</head>
<body>
  
 <p>A thumbnail image should now be displayed along side your customized tweets that link to your web pages content.</p>  

</body>
</html>

And here is the HTML code snippet to add a thumbnail image to your customized tweets that link to your articles web page using the <meta> elements for XHTML5 in the example below.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">  
<head>
 <meta charset="UTF-8" />
 <title>Welcome To XHTML5</title>
 <meta name="twitter:card" content="summary" />  
 <meta name="twitter:image" content="http://www.example.com/some-image.jpg" />  
 <meta name="twitter:description" content="Lets say you want to add a thumbnail image to your customized tweets that use Twitter's Summary Card format. For example, if you have an image that is associated with an article that has been tweeted you can give the tweeted links reader a preview of the content of your article along with the articles image before the reader clicks through to your web page." />  
 <meta name="twitter:title" content="HTML5 Snippets - Add A Thumbnail Image To Your Customized Tweets That Link To Your Articles Web Page Using The &lt;meta&gt; Element" />  
 <meta name="twitter:url" content="http://www.example.com/twitter-summary-card-with-a-thumbnail-image.htm" />  
</head>
<body>

 <p>A thumbnail image should now be displayed along side your customized tweets that link to your web pages content.</p>  

</body>
</html>

Article Tags

Tag Article (Sign in if you want to tag this article.)

Share This Article

Send To Facebook Link

Tweet This Link

Send To LinkedIn Link

Send To StumbleUpon Link

Digg This Link

Send To Google Plus One Share Link

Send To Reddit Link

Send To Tumblr Link

Send To Delicious Link

Send To FriendFeed Link

Send To Diigo Link

Email Link

AddThis Link

0 Comments

Leave Comment (Sign in and be the first to comment on this article.)

Important

This site cannot guarantee the accuracy of articles, comments, answers and other types of content or media submitted by members or anonymous users and guests, and we recommend that you use common sense when following any advice or information found on this site. Read our full Content Disclaimer Agreement for further information.