-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Force the 'data-embed-as' attribute to 'video' and make sure to show post text #13454
Changes from 2 commits
89638c2
1e600a4
d6e6d01
6fb6e9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,10 +49,16 @@ function getPostContainer(global, data) { | |
setStyle(c, 'text-align', 'center'); | ||
} | ||
const container = global.document.createElement('div'); | ||
const embedAs = data.embedAs || 'post'; | ||
let embedAs = data.embedAs || 'post'; | ||
user().assert(['post', 'video'].indexOf(embedAs) !== -1, | ||
'Attribute data-embed-as for <amp-facebook> value is wrong, should be' + | ||
' "post" or "video" was: %s', embedAs); | ||
// Force the `data-embed-as` attribute to 'video' and make sure to show the post's text. | ||
if (data.href.indexOf('/videos/') > 0) { | ||
embedAs = 'video'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, the behavior of this could be strange to a publisher if they explicitly set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, maybe in addition to the RegEx check, we also check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, made the change. |
||
container.setAttribute('data-embed-as', 'video'); | ||
container.setAttribute('data-show-text', 'true'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add a comment why show-text must be true for video. The reason is not obvious There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} | ||
container.className = 'fb-' + embedAs; | ||
container.setAttribute('data-href', data.href); | ||
return container; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would generate false positives if Facebook username has the word
videos
in it. Would need to tighten up the regex to only match*/(videos)/d+
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.