1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- defined('GNUSOCIAL') || die();
- class Attachment_thumbnailAction extends Attachment_viewAction
- {
- 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(): void
- {
-
- $filename = $this->filename;
- $filepath = $this->filepath;
- try {
- $thumbnail = $this->attachment->getThumbnail($this->thumb_w, $this->thumb_h, $this->thumb_c);
- $filename = $thumbnail->getFilename();
- $filepath = $thumbnail->getPath();
- } catch (UseFileAsThumbnailException $e) {
-
- } catch (FileNotFoundException $e) {
- $this->clientError(_m('No such attachment'), 404);
- } catch (Exception $e) {
- if (is_null($filepath)) {
- $this->clientError(_m('No such thumbnail'), 404);
- }
-
- }
-
-
-
- @ini_set('display_errors', 0);
- common_send_file($filepath, image_type_to_mime_type(IMAGETYPE_WEBP), $filename, 'inline');
- }
- }
|