123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class Attachment_thumbnailAction extends AttachmentAction
- {
- protected $thumb_w = null;
- protected $thumb_h = null;
- protected $thumb_c = null;
- protected function doPreparation()
- {
- parent::doPreparation();
- $this->thumb_w = $this->int('w');
- $this->thumb_h = $this->int('h');
- $this->thumb_c = $this->boolean('c');
- }
-
- public function showPage()
- {
-
- try {
- $thumbnail = $this->attachment->getThumbnail($this->thumb_w, $this->thumb_h, $this->thumb_c);
- $file = $thumbnail->getFile();
- } catch (UseFileAsThumbnailException $e) {
-
- $file = $e->file;
- } catch(FileNotFoundException $e) {
- $this->clientError(_('No such attachment'), 404);
- }
-
- $filepath = $file->getFileOrThumbnailPath($thumbnail);
- $filesize = $this->attachment->getFileOrThumbnailSize($thumbnail);
- $mimetype = $file->getFileOrThumbnailMimetype($thumbnail);
- $filename = MediaFile::getDisplayName($file);
-
-
-
- @ini_set('display_errors', 0);
- header("Content-Description: File Transfer");
- header("Content-Type: {$mimetype}");
- header("Content-Disposition: inline; filename=\"{$filename}\"");
- header('Expires: 0');
- header('Content-Transfer-Encoding: binary');
- AttachmentAction::sendFile($filepath, $filesize);
- }
- }
|