]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Output fixed sizes of thumbnails so we don't get jumpy scrolling
authorMikael Nordfeldth <mmn@hethane.se>
Fri, 1 Jan 2016 13:13:16 +0000 (14:13 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Fri, 1 Jan 2016 13:13:16 +0000 (14:13 +0100)
classes/File_thumbnail.php
lib/attachmentlistitem.php

index fb2515f9f5c02efd028205c45f48b8c318cb108c..e1eb79e099e69212b7f560919e09e8a3ce835852 100644 (file)
@@ -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))) {
index ab156bee92e5b6adbd08f3000bd46502e6aaaace..3a95eb10c3f3c3d92e9b31a934e9ecb96a00bbe6 100644 (file)
@@ -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) {