Skip to content

Commit

Permalink
#300 Issue #288: Support for Facebook data-locale attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
m4olivei authored Sep 24, 2021
2 parents a711d6c + c249dc5 commit 948c035
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Pass/FacebookNonIframeTransformPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,18 @@ protected function getFacebookEmbedAttrs(DOMQuery $el)
$height = $card ? self::DEFAULT_HEIGHT_WITH_CARD : self::DEFAULT_HEIGHT;
}

return [
$attrs = [
'data-href' => $src,
'data-embed-as' => $embed_as,
'height' => $height,
'width' => $width
];

// Set locale if exists.
if (!empty($el->attr('data-locale'))) {
$attrs['data-locale'] = $el->attr('data-locale');
}

return $attrs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@
class="fb-xfbml-parse-ignore">Posted by <a href="https://www.facebook.com/zuck">Mark Zuckerberg</a> on&nbsp;<a
href="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3">Wednesday,
September 14, 2011</a></blockquote>
</div>

<div class="fb-post"
data-href="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3"
data-width="500" data-show-text="true" data-locale="en">
<blockquote cite="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3"
class="fb-xfbml-parse-ignore">Posted by <a href="https://www.facebook.com/zuck">Mark Zuckerberg</a> on&nbsp;<a
href="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3">Wednesday,
September 14, 2011</a></blockquote>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

<amp-facebook layout="responsive" data-href="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3" data-embed-as="post" height="366" width="500"></amp-facebook>

<amp-facebook layout="responsive" data-href="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3" data-embed-as="post" height="366" width="500" data-locale="en"></amp-facebook>

ORIGINAL HTML
---------------
Line 1: <div id="fb-root"></div>
Expand Down Expand Up @@ -64,6 +66,15 @@ Line 48: class="fb-xfbml-parse-ignore">Posted by <a href="https:
Line 49: href="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3">Wednesday,
Line 50: September 14, 2011</a></blockquote>
Line 51: </div>
Line 52:
Line 53: <div class="fb-post"
Line 54: data-href="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3"
Line 55: data-width="500" data-show-text="true" data-locale="en">
Line 56: <blockquote cite="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3"
Line 57: class="fb-xfbml-parse-ignore">Posted by <a href="https://www.facebook.com/zuck">Mark Zuckerberg</a> on&nbsp;<a
Line 58: href="https://www.facebook.com/photo.php?fbid=986393557241&amp;set=a.941146602501.2418915.4&amp;type=3">Wednesday,
Line 59: September 14, 2011</a></blockquote>
Line 60: </div>


Transformations made from HTML tags to AMP custom tags
Expand All @@ -87,6 +98,9 @@ Transformations made from HTML tags to AMP custom tags
<div class="fb-post" data-href="https://www.facebook.com/photo.php?fbid=986393557241&set=a.941146602501.2418915.4&type=3" data-width="500" data-show-text="true"> at line 46
ACTION TAKEN: div.fb-post facebook javascript sdk embed code was converted to the amp-facebook tag.

<div class="fb-post" data-href="https://www.facebook.com/photo.php?fbid=986393557241&set=a.941146602501.2418915.4&type=3" data-width="500" data-show-text="true" data-locale="en"> at line 55
ACTION TAKEN: div.fb-post facebook javascript sdk embed code was converted to the amp-facebook tag.


AMP-HTML Validation Issues and Fixes
-------------------------------------
Expand Down

0 comments on commit 948c035

Please sign in to comment.