* @link http://status.net/
*/
-if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); }
+if (!defined('GNUSOCIAL')) { exit(1); }
/**
* Show notice attachments
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(), 302);
+ }
+
+ common_redirect(File_thumbnail::url($thumbnail->filename), 302);
}
}