diff --git a/actions/attachment_download.php b/actions/attachment_download.php new file mode 100644 index 0000000000..6792c45993 --- /dev/null +++ b/actions/attachment_download.php @@ -0,0 +1,20 @@ + + * @license https://www.gnu.org/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link https:/gnu.io/social + */ +class Attachment_downloadAction extends AttachmentAction +{ + public function showPage() + { + common_redirect($this->attachment->getUrl(), 302); + } +} diff --git a/classes/File.php b/classes/File.php index 46d4d5498d..c85d919fd7 100644 --- a/classes/File.php +++ b/classes/File.php @@ -478,6 +478,8 @@ class File extends Managed_DataObject * @param $width int Max width of thumbnail in pixels. (if null, use common_config values) * @param $height int Max height of thumbnail in pixels. (if null, square-crop to $width) * @param $crop bool Crop to the max-values' aspect ratio + * @param $force_still bool Don't allow fallback to showing original (such as animated GIF) + * @param $upscale mixed Whether or not to scale smaller images up to larger thumbnail sizes. (null = site default) * * @return File_thumbnail * @@ -498,7 +500,7 @@ class File extends Managed_DataObject return File_thumbnail::byFile($this); } catch (NoResultException $e) { // and if it's not a remote file, it'll be safe to use the locally stored File - throw new UseFileAsThumbnailException($this->id); + throw new UseFileAsThumbnailException($this); } } } diff --git a/lib/accountmover.php b/lib/accountmover.php index 83314b4997..f8fb4512bd 100644 --- a/lib/accountmover.php +++ b/lib/accountmover.php @@ -114,7 +114,6 @@ class AccountMover extends QueueHandler $svcDocUrl = $link->href; if (isset($link['http://apinamespace.org/atom/username'])) { $username = $link['http://apinamespace.org/atom/username']; - break; } } diff --git a/lib/imagefile.php b/lib/imagefile.php index 85fc597126..b0cd13089f 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -132,7 +132,7 @@ class ImageFile // First some mimetype specific exceptions switch ($file->mimetype) { case 'image/svg+xml': - throw new UseFileAsThumbnailException($file->id); + throw new UseFileAsThumbnailException($file); } // And we'll only consider it an image if it has such a media type @@ -282,7 +282,11 @@ class ImageFile } if (!file_exists($outpath)) { - throw new UseFileAsThumbnailException($this->id); + if ($this->fileRecord instanceof File) { + throw new UseFileAsThumbnailException($this->fileRecord); + } else { + throw new UnsupportedMediaException('No local File object exists for ImageFile.'); + } } return $outpath; @@ -544,7 +548,7 @@ class ImageFile } fclose($fh); - return $count > 1; + return $count >= 1; // number of animated frames apart from the original image } public function getFileThumbnail($width, $height, $crop, $upscale=false) diff --git a/lib/router.php b/lib/router.php index 5a51f3d7d4..b01c9a7677 100644 --- a/lib/router.php +++ b/lib/router.php @@ -223,6 +223,10 @@ class Router array('action' => 'attachment'), array('attachment' => '[0-9]+')); + $m->connect('attachment/:attachment/download', + array('action' => 'attachment_download'), + array('attachment' => '[0-9]+')); + $m->connect('attachment/:attachment/thumbnail', array('action' => 'attachment_thumbnail'), array('attachment' => '[0-9]+')); diff --git a/lib/usefileasthumbnailexception.php b/lib/usefileasthumbnailexception.php index cafbe692b2..5ad33cb0a9 100644 --- a/lib/usefileasthumbnailexception.php +++ b/lib/usefileasthumbnailexception.php @@ -34,13 +34,9 @@ class UseFileAsThumbnailException extends UnsupportedMediaException { public $file = null; - public function __construct($file_id) + public function __construct(File $file) { - $this->file = File::getKV('id', $file_id); - if (!$this->file instanceof File) { - throw new ServerException('No File ID supplied to exception'); - } - + $this->file = $file; parent::__construct('Thumbnail not generated', $this->file->getPath()); } } diff --git a/lib/useractivitystream.php b/lib/useractivitystream.php index bb60485164..cc0e4297e6 100644 --- a/lib/useractivitystream.php +++ b/lib/useractivitystream.php @@ -219,7 +219,6 @@ class UserActivityStream extends AtomUserNoticeFeed } } catch (Exception $e) { common_log(LOG_ERR, $e->getMessage()); - continue; } } } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 03cb4644ee..e87e87fbf8 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -851,6 +851,8 @@ clear:both; } #attachment_view img, #attachment_view .attachment_player { +height: auto; +width: auto; max-width:480px; max-height:480px; }