From 98f831dd204d6834109a7027378b4a924844a3a8 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Thu, 21 Jan 2016 20:01:43 +0100 Subject: [PATCH] thumbnails in oembed response and better looking rendering of oembed coming from other qvitter instances --- actions/apiqvitteroembednotice.php | 28 +++++++++++++++++++++++++--- css/qvitter.css | 2 +- js/dom-functions.js | 20 ++++++++++++++++++-- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/actions/apiqvitteroembednotice.php b/actions/apiqvitteroembednotice.php index bfe9455..15f0c85 100644 --- a/actions/apiqvitteroembednotice.php +++ b/actions/apiqvitteroembednotice.php @@ -108,16 +108,38 @@ class ApiQvitterOembedNoticeAction extends ApiAction $oembed['version']='1.0'; $oembed['provider_name']=common_config('site', 'name'); $oembed['provider_url']=common_root_url(); + $oembed['type']='link'; // TRANS: oEmbed title. %1$s is the author name, %2$s is the creation date. - $oembed['title'] = sprintf(_('%1$s\'s status on %2$s'), - $authorname, - common_exact_date($notice->created)); + $oembed['title'] = ApiAction::dateTwitter($notice->created).' (Qvitter)'; $oembed['author_name']=$authorname; $oembed['author_url']=$profile->profileurl; $oembed['url']=$notice->getUrl(); $oembed['html']=$notice->getRendered(); + // maybe add thumbnail + $attachments = $notice->attachments(); + if (!empty($attachments)) { + foreach ($attachments as $attachment) { + if(is_object($attachment)) { + try { + $thumb = $attachment->getThumbnail(); + } catch (ServerException $e) { + // + } + if(method_exists('File_thumbnail','url')) { + try { + $thumb_url = File_thumbnail::url($thumb->filename); + $oembed['thumbnail_url'] = $thumb_url; + break; // only first one + } catch (ClientException $e) { + // + } + } + } + } + } + if($this->format == 'json') { $this->initDocument('json'); print json_encode($oembed); diff --git a/css/qvitter.css b/css/qvitter.css index 58b5e38..ee0d292 100644 --- a/css/qvitter.css +++ b/css/qvitter.css @@ -2132,7 +2132,7 @@ body.rtl .queet.rtl .expanded-content { text-overflow: ellipsis; white-space: nowrap; } -.oembed-twitter-username { +.oembed-username { font-size:13px; color:#999; font-weight:normal; diff --git a/js/dom-functions.js b/js/dom-functions.js index b04a05f..ec8a7e6 100644 --- a/js/dom-functions.js +++ b/js/dom-functions.js @@ -2202,7 +2202,7 @@ function buildAttachmentHTML(attachments){ var twitterHTML = '
\ ' + this.oembed.author_name + '\ - ' + this.oembed.title + '\ + ' + this.oembed.title + '\
\
' + this.oembed.oembedHTML + '
\