Output fixed sizes of thumbnails so we don't get jumpy scrolling
This commit is contained in:
parent
4fc2b2584b
commit
86106b890a
@ -153,6 +153,26 @@ class File_thumbnail extends Managed_DataObject
|
|||||||
return $this->url;
|
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)
|
public function delete($useWhere=false)
|
||||||
{
|
{
|
||||||
if (!empty($this->filename) && file_exists(File_thumbnail::path($this->filename))) {
|
if (!empty($this->filename) && file_exists(File_thumbnail::path($this->filename))) {
|
||||||
|
@ -120,7 +120,7 @@ class AttachmentListItem extends Widget
|
|||||||
try {
|
try {
|
||||||
// Tell getThumbnail that we can show an animated image if it has one (4th arg, "force_still")
|
// 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);
|
$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) {
|
} catch (UseFileAsThumbnailException $e) {
|
||||||
$this->out->element('img', array('class'=>'u-photo', 'src' => $e->file->getUrl(), 'alt' => $e->file->title));
|
$this->out->element('img', array('class'=>'u-photo', 'src' => $e->file->getUrl(), 'alt' => $e->file->title));
|
||||||
} catch (UnsupportedMediaException $e) {
|
} catch (UnsupportedMediaException $e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user