summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/shortcodes/facebook.php')
-rw-r--r--plugins/jetpack/modules/shortcodes/facebook.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/plugins/jetpack/modules/shortcodes/facebook.php b/plugins/jetpack/modules/shortcodes/facebook.php
index 778fc543..ab7a04f4 100644
--- a/plugins/jetpack/modules/shortcodes/facebook.php
+++ b/plugins/jetpack/modules/shortcodes/facebook.php
@@ -32,7 +32,14 @@ function jetpack_facebook_embed_handler( $matches, $attr, $url ) {
if ( false !== strpos( $url, 'video.php' ) || false !== strpos( $url, '/videos/' ) ) {
$embed = sprintf( '<div class="fb-video" data-allowfullscreen="true" data-href="%s"></div>', esc_url( $url ) );
} else {
- $embed = sprintf( '<fb:post href="%s"></fb:post>', esc_url( $url ) );
+ $width = 552; // As of 01/2017, the default width of Facebook embeds when no width attribute provided
+
+ global $content_width;
+ if ( isset( $content_width ) ) {
+ $width = min( $width, $content_width );
+ }
+
+ $embed = sprintf( '<fb:post href="%s" data-width="%s"></fb:post>', esc_url( $url ), esc_attr( $width ) );
}
// since Facebook is a faux embed, we need to load the JS SDK in the wpview embed iframe