From be2769244f4478d1ac0692d780a23d24c34bce91 Mon Sep 17 00:00:00 2001 From: mikeyc7m Date: Mon, 29 Feb 2016 12:19:34 +1100 Subject: [PATCH] fix to support facebook autodiscover the autodiscover function was failing on facebook because it returned the wrong match. also added a thumbnail lookup for facebook. --- oembed/Oembed.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/oembed/Oembed.php b/oembed/Oembed.php index 0c8c55cc6..7918c8407 100644 --- a/oembed/Oembed.php +++ b/oembed/Oembed.php @@ -117,12 +117,12 @@ class Oembed { if(preg_match_all($pcreOmbed, $body, $matches, PREG_SET_ORDER)) { $match = $matches[0]; - if(!empty($match[1])) { - return html_entity_decode($match[1]); - } if(!empty($match[2])) { return html_entity_decode($match[2]); } + if(!empty($match[1])) { + return html_entity_decode($match[1]); + } } return false; } @@ -297,6 +297,11 @@ class Oembed_Result extends ViewableData { // Convert all keys to lowercase $data = array_change_key_case($data, CASE_LOWER); + if( isset($data['provider_name']) && $data['provider_name'] == "Facebook" ) { + $id = preg_replace("/.*\/(\d+?)\/?($|\?.*)/", "$1", $data["url"]); + $data['thumbnail_url'] = "https://graph.facebook.com/{$id}/picture"; + } + // Purge everything if the type does not match. if($this->type && $this->type != $data['type']) { $data = array();