-
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
Conversation
@cvializ could you take a look at the PR? |
3p/facebook.js
Outdated
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 comment
The 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 data-embed-as="post"
but this auto-changes it to video
. Is it always better the change the value to video
because the user experience is broken with post-videos?
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.
Agree, maybe in addition to the RegEx check, we also check if data.embedAs
is falsey meaning user did not explicitly specify a type?
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.
Good point, made the change.
3p/facebook.js
Outdated
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) { |
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.
3p/facebook.js
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, maybe in addition to the RegEx check, we also check if data.embedAs
is falsey meaning user did not explicitly specify a type?
3p/facebook.js
Outdated
if (data.href.indexOf('/videos/') > 0) { | ||
embedAs = 'video'; | ||
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Done
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.
@aghassemi @cvializ PTAL?
3p/facebook.js
Outdated
if (data.href.indexOf('/videos/') > 0) { | ||
embedAs = 'video'; | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Done
3p/facebook.js
Outdated
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) { |
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.
3p/facebook.js
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, made the change.
287147a
to
d6e6d01
Compare
@aghassemi could you merge the CL? |
…post text (ampproject#13454) * Force the 'data-embed-as' attribute to 'video' and make sure to show the post's text. * Strengthen regex and force data-embed-as attribute when not specifically set
Fixes #12088
It does so by:
data-embed-as
for all videos to 'video'data-show-text
to 'true' (changed from the default 'false')Initially the issue would repro when switching from desktop to mobile mode in Chrome devtools as well.