X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Fattachment_thumbnail.php;h=e8f89ffc360d45c505aefd5198e4927e9b04a8ec;hb=ad3b62cf2f857d53113692f5a12adce616f17829;hp=b5173efa771dfca0969e4d118be7dee24b836d04;hpb=c862b3f35505e0a862f69b08e88a4dd294fc43e9;p=quix0rs-gnu-social.git diff --git a/actions/attachment_thumbnail.php b/actions/attachment_thumbnail.php index b5173efa77..e8f89ffc36 100644 --- a/actions/attachment_thumbnail.php +++ b/actions/attachment_thumbnail.php @@ -27,7 +27,7 @@ * @link http://status.net/ */ -if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); } +if (!defined('GNUSOCIAL')) { exit(1); } /** * Show notice attachments @@ -44,26 +44,24 @@ class Attachment_thumbnailAction extends AttachmentAction protected $thumb_h = null; // max height protected $thumb_c = null; // crop? - protected function prepare(array $args=array()) + protected function doPreparation() { - parent::prepare($args); + parent::doPreparation(); $this->thumb_w = $this->int('w'); $this->thumb_h = $this->int('h'); $this->thumb_c = $this->boolean('c'); - - return true; } - /** - * Show page, a template method. - * - * @return nothing - */ - function showPage() + public function showPage() { // Returns a File_thumbnail object or throws exception if not available - $thumbnail = $this->attachment->getThumbnail($this->thumb_w, $this->thumb_h, $this->thumb_c); - common_redirect($thumbnail->getUrl()); + try { + $thumbnail = $this->attachment->getThumbnail($this->thumb_w, $this->thumb_h, $this->thumb_c); + } catch (UseFileAsThumbnailException $e) { + common_redirect($e->file->getUrl()); + } + + common_redirect(File_thumbnail::url($thumbnail->filename)); } }