forked from GNUsocial/gnu-social
Default to avoid upscaling of thumbnails. 45x45=>450x450 is ugly
This commit is contained in:
parent
dd229e855a
commit
8806cce735
@ -150,7 +150,7 @@ class ImageFile
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$image = new ImageFile($file->id, $imgPath);
|
$image = new ImageFile($file->getID(), $imgPath);
|
||||||
} catch (UnsupportedMediaException $e) {
|
} catch (UnsupportedMediaException $e) {
|
||||||
// Avoid deleting the original
|
// Avoid deleting the original
|
||||||
if ($imgPath != $file->getPath()) {
|
if ($imgPath != $file->getPath()) {
|
||||||
@ -541,7 +541,7 @@ class ImageFile
|
|||||||
return $count > 1;
|
return $count > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFileThumbnail($width, $height, $crop)
|
public function getFileThumbnail($width, $height, $crop, $upscale=false)
|
||||||
{
|
{
|
||||||
if (!$this->fileRecord instanceof File) {
|
if (!$this->fileRecord instanceof File) {
|
||||||
throw new ServerException('No File object attached to this ImageFile object.');
|
throw new ServerException('No File object attached to this ImageFile object.');
|
||||||
@ -553,6 +553,15 @@ class ImageFile
|
|||||||
$crop = common_config('thumbnail', 'crop');
|
$crop = common_config('thumbnail', 'crop');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$upscale) {
|
||||||
|
if ($width > $this->width) {
|
||||||
|
$width = $this->width;
|
||||||
|
}
|
||||||
|
if (!is_null($height) && $height > $this->height) {
|
||||||
|
$height = $this->height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($height === null) {
|
if ($height === null) {
|
||||||
$height = $width;
|
$height = $width;
|
||||||
$crop = true;
|
$crop = true;
|
||||||
@ -602,8 +611,8 @@ class ImageFile
|
|||||||
if ($this->getPath() != File_thumbnail::path($this->filename)) {
|
if ($this->getPath() != File_thumbnail::path($this->filename)) {
|
||||||
$this->unlink();
|
$this->unlink();
|
||||||
}
|
}
|
||||||
return File_thumbnail::saveThumbnail($this->fileRecord->id,
|
return File_thumbnail::saveThumbnail($this->fileRecord->getID(),
|
||||||
File_thumbnail::url($outname),
|
null, // no url since we generated it ourselves and can dynamically generate the url
|
||||||
$width, $height,
|
$width, $height,
|
||||||
$outname);
|
$outname);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user