Twitter Card (photo) is showing error in the validator tool, but all single tags are valid

StackOverflow https://stackoverflow.com/questions/23097050

  •  04-07-2023
  •  | 
  •  

Question

I'm trying to add twitter card support for our own image server. Currently the meta tags are like:

<meta name="twitter:card" content="photo">
<meta name="twitter:site" content="@FotoDish">
<meta name="twitter:creator" content="@FotoDish">
<meta name="twitter:title" content="FotoDish">
<meta name="twitter:image:src" content="http://img.fotodish.com/upload/534d5a08a15537a840cafe8e">
<meta name="twitter:domain" content="fotodish.com">

as in http://fdi.sh/i/534d5a08a15537a840cafe8e .

However, the validator tool shows error, while all single items are valid.

Twitter Validator Tool result

What is the issue?

Thank you!

Était-ce utile?

La solution

I eventually find the reason... It was a little tricky and Twitter didn't say anything about it in any docs, which is ....

You need to set the Content-Type of the image correctly.

In my situation, I used Amazon S3 and Cloudfront for image storage. When I uploaded the images to S3, I didn't set the MIME type so S3 used application/octet-stream as the default value. In this case, the images could be shown in an img tag correctly, but would not be treated as an image by Twitter bot.

So I just reset the Content-Type of all the images to 'image/png' (or whatever they should be) and everything was all good.

P.S. Also make sure that you have your robot.txt allow Twitterbot to access.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top