better parsing of twitter's oembed data

This commit is contained in:
Hannes Mannerheim 2016-01-27 13:59:23 +01:00
parent 19db6dd8fe
commit 094ed63c17

View File

@ -519,9 +519,10 @@ 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, '<div>&mdash;')) { error_log('$oembed_html: '.$oembed_html);
$oembed_html = substr($oembed_html,0,strpos($oembed_html, '<div>&mdash;')); // remove user data from twitter oembed html (we have it in ) if($oembed->provider == 'Twitter' && strstr($oembed_html, '>&mdash; '.$oembed->author_name)) {
$twitter_username = substr($oembed->html,strpos($oembed->html, '<div>&mdash;')+12); $oembed_html = substr($oembed_html,0,strpos($oembed_html, '>&mdash; '.$oembed->author_name)+1); // remove user data from twitter oembed html (we have it in )
$twitter_username = substr($oembed->html,strpos($oembed->html, '>&mdash; '.$oembed->author_name)+strlen('>&mdash; '.$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;