From: Roland Haeder Date: Sun, 15 Feb 2015 21:46:00 +0000 (+0100) Subject: Merge branch 'master' into social-master X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f8e7d426530e02fd10c6756668c6338a01f78a4b;p=quix0rs-gnu-social.git Merge branch 'master' into social-master Conflicts: classes/File.php plugins/Recaptcha/RecaptchaPlugin.php plugins/UserLimit/UserLimitPlugin.php Signed-off-by: Roland Haeder --- f8e7d426530e02fd10c6756668c6338a01f78a4b diff --cc classes/File.php index 9bb22e502b,ce2f940161..1fcc83dd88 --- a/classes/File.php +++ b/classes/File.php @@@ -382,16 -382,19 +382,19 @@@ class File extends Managed_DataObjec * * @return File_thumbnail */ - public function getThumbnail($width=null, $height=null, $crop=false) + public function getThumbnail($width=null, $height=null, $crop=false, $force_still=true) { - if (intval($this->width) < 1 || intval($this->height) < 1) { - // Old files may have 0 until migrated with scripts/upgrade.php - // For any legitimately unrepresentable ones, we could generate our - // own image (like a square with MIME type in text) - throw new UnsupportedMediaException('No image geometry available.'); + // Get some more information about this file through our ImageFile class + $image = ImageFile::fromFileObject($this); + 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) { + if ($width === null || $width < 1) { $width = common_config('thumbnail', 'width'); $height = common_config('thumbnail', 'height'); $crop = common_config('thumbnail', 'crop'); @@@ -432,25 -431,14 +434,26 @@@ // Doublecheck that parameters are sane and integers. if ($box['width'] < 1 || $box['width'] > common_config('thumbnail', 'maxsize') || $box['height'] < 1 || $box['height'] > common_config('thumbnail', 'maxsize') - || $box['w'] < 1 || $box['x'] >= $this->width - || $box['h'] < 1 || $box['y'] >= $this->height) { + || $box['w'] < 1 || $box['x'] >= $image->width + || $box['h'] < 1 || $box['y'] >= $image->height) { // Fail on bad width parameter. If this occurs, it's due to algorithm in ImageFile->scaleToFit - common_debug("Boundary box parameters for resize of {$image->filepath} : ".var_export($box,true)); - throw new ServerException('Bad thumbnail size parameters.'); + common_debug("Boundary box parameters for resize of {$this->filepath} : ".var_export($box,true)); + throw new ServerException('Bad thumbnail size parameters. maxsize=' . + common_config('thumbnail', 'maxsize') . + ',box[width]=' . $box['width'] . + ',box[height]=' . $box['height'] . + ',box[w]=' . $box['w'] . + ',box[h]=' . $box['h'] . + ',box[x]=' . $box['x'] . + ',box[y]=' . $box['y'] . + ',this->width=' . $this->width . + ',this->heigh=' . $this->height . + ',this->filepath=' . $this->filepath . + ',this->filename=' . $this->filename + ); } + common_debug(sprintf('Generating a thumbnail of File id==%u of size %ux%u', $this->id, $width, $height)); // Perform resize and store into file $image->resizeTo($outpath, $box);