forked from GNUsocial/gnu-social
Improved animated image thumbnail freedom of choice
Default is now to take still thumbnails of animated GIFs and then show them as originals in an AttachmentListItem. The still frames are mostly used with front-ends like qvitter.
This commit is contained in:
parent
7beec74f0c
commit
67d09532dd
@ -382,13 +382,17 @@ class File extends Managed_DataObject
|
||||
*
|
||||
* @return File_thumbnail
|
||||
*/
|
||||
public function getThumbnail($width=null, $height=null, $crop=false)
|
||||
public function getThumbnail($width=null, $height=null, $crop=false, $force_still=true)
|
||||
{
|
||||
// Get some more information about this file through our ImageFile class
|
||||
$image = ImageFile::fromFileObject($this);
|
||||
if ($image->animated && is_null(common_config('thumbnail', 'animated'))) {
|
||||
if ($image->animated && !common_config('thumbnail', 'animated')) {
|
||||
// null means "always use file as thumbnail"
|
||||
// false means you get choice between frozen frame or original when calling getThumbnail
|
||||
if (is_null(common_config('thumbnail', 'animated')) || !$force_still) {
|
||||
throw new UseFileAsThumbnailException($this->id);
|
||||
}
|
||||
}
|
||||
|
||||
if ($width === null) {
|
||||
$width = common_config('thumbnail', 'width');
|
||||
|
@ -113,7 +113,8 @@ class AttachmentListItem extends Widget
|
||||
case 'image/jpg':
|
||||
case 'image/jpeg':
|
||||
try {
|
||||
$thumb = $this->attachment->getThumbnail();
|
||||
// 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' => ''));
|
||||
} catch (UseFileAsThumbnailException $e) {
|
||||
$this->out->element('img', array('class'=>'u-photo', 'src' => $e->file->getUrl(), 'alt' => $e->file->title));
|
||||
|
@ -258,7 +258,7 @@ $default =
|
||||
'maxsize' => 1000, // thumbs with an edge larger than this will not be generated
|
||||
'width' => 450,
|
||||
'height' => 600,
|
||||
'animated' => null), // null="UseFileAsThumbnail", false="take still image". true requires ImageMagickPlugin
|
||||
'animated' => false), // null="UseFileAsThumbnail", false="can use still frame". true requires ImageMagickPlugin
|
||||
'application' =>
|
||||
array('desclimit' => null),
|
||||
'group' =>
|
||||
|
Loading…
Reference in New Issue
Block a user