more oembed fixes

This commit is contained in:
Hannes Mannerheim 2016-01-20 19:06:21 +01:00
parent 1b00c75700
commit ba1816a6fd
2 changed files with 10 additions and 13 deletions

View File

@ -517,10 +517,13 @@ class QvitterPlugin extends Plugin {
if(array_key_exists('Oembed', StatusNet::getActivePlugins())) { if(array_key_exists('Oembed', StatusNet::getActivePlugins())) {
$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); // ellipsis is sometimes stored as html in db, for some reason
$oembed_html = strip_tags($oembed_html);
$attachment_url_to_id[$enclosure_o->url]['oembed'] = array( $attachment_url_to_id[$enclosure_o->url]['oembed'] = array(
'provider'=> $oembed->provider, 'provider'=> $oembed->provider,
'provider_url'=> $oembed->provider_url, 'provider_url'=> $oembed->provider_url,
'oembedHTML'=> strip_tags($oembed->html), 'oembedHTML'=> $oembed_html,
'title'=> $oembed->title, 'title'=> $oembed->title,
'author_url'=> $oembed->author_url 'author_url'=> $oembed->author_url
); );

View File

@ -2182,20 +2182,14 @@ function buildAttachmentHTML(attachments){
var oembedBody = ''; var oembedBody = '';
try { // not if html it's the same as the title (wordpress does this..)
var oembedStrippedHTML = $.trim($('<div>' + this.oembed.oembedHTML + '</div>').text().replace('<!--//-->',''));
}
catch(e) {
var oembedStrippedHTML = '';
}
// not if stripped from html it's the same as the title (wordpress does this..)
if(this.oembed.oembedHTML !== null if(this.oembed.oembedHTML !== null
&& oembedStrippedHTML.length > 0 && this.oembed.oembedHTML.length > 0
&& oembedStrippedHTML != $.trim(this.oembed.title)) { && $.trim(this.oembed.oembedHTML) != $.trim(this.oembed.title)) {
if(oembedStrippedHTML.length > 160) { if(this.oembed.oembedHTML.length > 200) {
oembedStrippedHTML = oembedStrippedHTML.substring(0,250) + '…'; this.oembed.oembedHTML = this.oembed.oembedHTML.substring(0,200) + '…';
} }
oembedBody = oembedStrippedHTML; oembedBody = this.oembed.oembedHTML;
} }
if(this.oembed.provider === null) { if(this.oembed.provider === null) {