oembed fixes

This commit is contained in:
Hannes Mannerheim 2016-02-25 11:08:47 +01:00
parent f977f9ba8a
commit 131f9a673d

View File

@ -528,16 +528,16 @@ class QvitterPlugin extends Plugin {
$oembed = File_oembed::getKV('file_id',$attachment->id); $oembed = File_oembed::getKV('file_id',$attachment->id);
if($oembed instanceof File_oembed) { if($oembed instanceof File_oembed) {
$oembed_html = str_replace('<!--//-->','',$oembed->html); // trash left of wordpress' javascript after htmLawed removed the tags $oembed_html = str_replace('<!--//-->','',$oembed->html); // trash left of wordpress' javascript after htmLawed removed the tags
if($oembed->provider == 'Twitter' && strstr($oembed_html, '>— '.$oembed->author_name)) { if($oembed->provider == 'Twitter' && strstr($oembed_html, '> '.$oembed->author_name)) {
$oembed_html = substr($oembed_html,0,strpos($oembed_html, '>— '.$oembed->author_name)+1); // remove user data from twitter oembed html (we have it in ) $oembed_html = substr($oembed_html,0,strpos($oembed_html, '> '.$oembed->author_name)+1); // remove user data from twitter oembed html (we have it in )
$twitter_username = substr($oembed->html,strpos($oembed->html, '>— '.$oembed->author_name)+strlen('>— '.$oembed->author_name)); $twitter_username = substr($oembed->html,strpos($oembed->html, '> '.$oembed->author_name)+strlen('> '.$oembed->author_name));
$twitter_username = substr($twitter_username, strpos($twitter_username,'(@')+1); $twitter_username = substr($twitter_username, strpos($twitter_username,'(@')+1);
$twitter_username = substr($twitter_username, 0,strpos($twitter_username,')')); $twitter_username = substr($twitter_username, 0,strpos($twitter_username,')'));
$oembed->title = $twitter_username; $oembed->title = $twitter_username;
} }
$oembed_html = str_replace('…','...',$oembed_html); // ellipsis is sometimes stored as html in db, for some reason $oembed_html = str_replace('…','...',$oembed_html); // ellipsis is sometimes stored as html in db, for some reason
$oembed_html = mb_substr(trim(strip_tags(html_entity_decode($oembed_html,ENT_QUOTES))),0,250); // sometimes we have html charachters that we want to decode and then strip $oembed_html = mb_substr(trim(strip_tags($oembed_html)),0,250);
$oembed_title = trim(strip_tags(html_entity_decode($oembed->title,ENT_QUOTES))); $oembed_title = trim(strip_tags(html_entity_decode($oembed->title,ENT_QUOTES))); // sometimes we have html charachters that we want to decode and then strip
$oembed_provider = trim(strip_tags(html_entity_decode($oembed->provider,ENT_QUOTES))); $oembed_provider = trim(strip_tags(html_entity_decode($oembed->provider,ENT_QUOTES)));
$oembed_author_name = trim(strip_tags(html_entity_decode($oembed->author_name,ENT_QUOTES))); $oembed_author_name = trim(strip_tags(html_entity_decode($oembed->author_name,ENT_QUOTES)));
$attachment_url_to_id[$enclosure_o->url]['oembed'] = array( $attachment_url_to_id[$enclosure_o->url]['oembed'] = array(