X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fattachmentlist.php;h=4d4b4511672aa0167697df58727a81a07533ce6d;hb=d4be5349b30f49fa049dbfc854bb2a95eeb1d5c1;hp=35584912787615c74a12dcf9d08ba1b678516eab;hpb=b48e3a22bf4db72bc5779f95b7dc5fb9c9a5653b;p=quix0rs-gnu-social.git diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 3558491278..4d4b451167 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -58,7 +58,7 @@ class AttachmentList extends Widget * * @param Notice $notice stream of notices from DB_DataObject */ - function __construct($notice, $out=null) + function __construct(Notice $notice, $out=null) { parent::__construct($out); $this->notice = $notice; @@ -74,23 +74,32 @@ class AttachmentList extends Widget */ function show() { - $att = $this->notice->attachments(); - if (empty($att)) return 0; + $attachments = $this->notice->attachments(); + foreach ($attachments as $key=>$att) { + // Remove attachments which are not representable with neither a title nor thumbnail + if ($att->getTitle() === null && !$att->hasThumbnail()) { + unset($attachments[$key]); + } + } + if (!count($attachments)) { + return 0; + } + $this->showListStart(); - foreach ($att as $n=>$attachment) { - $item = $this->newListItem($attachment); + foreach ($attachments as $att) { + $item = $this->newListItem($att); $item->show(); } $this->showListEnd(); - return count($att); + return count($attachments); } function showListStart() { - $this->out->elementStart('ol', array('class' => 'attachments entry-content')); + $this->out->elementStart('ol', array('class' => 'attachments')); } function showListEnd()