Skip to content

Commit

Permalink
Update attribute names for twitter cards
Browse files Browse the repository at this point in the history
In the HTML parser, the attribute name was set to `value` rather than
`content` for the `twitter:image` and `twitter:title` selectors. Per
Twitter’s documentation, this attribute should be `content`. (See:
https://dev.twitter.com/cards/types/summary) This causes valid HTML
pages with correct Twitter card syntax to return an empty cover and
title. For example, this URL:
http://www.huffingtonpost.com/entry/the-missing-voice-the-missing-piece-
where-are-the_us_576f5617e4b0fa01a14027df
  • Loading branch information
benwilkins committed May 25, 2017
1 parent 81926bc commit 315aa78
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Parsers/HtmlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ class HtmlParser extends BaseParser implements ParserInterface
*/
private $tags = [
'cover' => [
['selector' => 'meta[property="twitter:image"]', 'attribute' => 'value'],
['selector' => 'meta[property="twitter:image"]', 'attribute' => 'content'],
['selector' => 'meta[property="og:image"]', 'attribute' => 'content'],
['selector' => 'meta[itemprop="image"]', 'attribute' => 'content'],
],

'title' => [
['selector' => 'meta[property="twitter:title"]', 'attribute' => 'value'],
['selector' => 'meta[property="twitter:title"]', 'attribute' => 'content'],
['selector' => 'meta[property="og:title"]', 'attribute' => 'content'],
['selector' => 'meta[itemprop="name"]', 'attribute' => 'content'],
['selector' => 'title']
Expand Down

0 comments on commit 315aa78

Please sign in to comment.