From: Mikael Nordfeldth Date: Fri, 1 Jan 2016 13:13:16 +0000 (+0100) Subject: Output fixed sizes of thumbnails so we don't get jumpy scrolling X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;ds=sidebyside;h=86106b890a45c9cd3f965259ecbed551ac55a9db;p=quix0rs-gnu-social.git Output fixed sizes of thumbnails so we don't get jumpy scrolling --- diff --git a/classes/File_thumbnail.php b/classes/File_thumbnail.php index fb2515f9f5..e1eb79e099 100644 --- a/classes/File_thumbnail.php +++ b/classes/File_thumbnail.php @@ -153,6 +153,26 @@ class File_thumbnail extends Managed_DataObject return $this->url; } + public function getHeight() + { + return $this->height; + } + + public function getWidth() + { + return $this->width; + } + + public function getHtmlAttrs(array $orig=array(), $overwrite=true) + { + $attrs = [ + 'height' => $this->getHeight(), + 'width' => $this->getWidth(), + 'src' => $this->getUrl(), + ]; + return $overwrite ? array_merge($orig, $attrs) : array_merge($attrs, $orig); + } + public function delete($useWhere=false) { if (!empty($this->filename) && file_exists(File_thumbnail::path($this->filename))) { diff --git a/lib/attachmentlistitem.php b/lib/attachmentlistitem.php index ab156bee92..3a95eb10c3 100644 --- a/lib/attachmentlistitem.php +++ b/lib/attachmentlistitem.php @@ -120,7 +120,7 @@ class AttachmentListItem extends Widget try { // Tell getThumbnail that we can show an animated image if it has one (4th arg, "force_still") $thumb = $this->attachment->getThumbnail(null, null, false, false); - $this->out->element('img', array('class'=>'u-photo', 'src' => $thumb->getUrl(), 'alt' => '')); + $this->out->element('img', $thumb->getHtmlAttrs(['class'=>'u-photo', 'alt' => ''])); } catch (UseFileAsThumbnailException $e) { $this->out->element('img', array('class'=>'u-photo', 'src' => $e->file->getUrl(), 'alt' => $e->file->title)); } catch (UnsupportedMediaException $e) {