X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fattachment_thumbnail.php;h=b5173efa771dfca0969e4d118be7dee24b836d04;hb=c075b9f73068066897f2d42cdbcf1be1bf812380;hp=e27480424d79c0627031d22894fd5e0cd2e15985;hpb=ae883ceb9b4689f6c1dd3aecdc4a844eda7d179a;p=quix0rs-gnu-social.git diff --git a/actions/attachment_thumbnail.php b/actions/attachment_thumbnail.php index e27480424d..b5173efa77 100644 --- a/actions/attachment_thumbnail.php +++ b/actions/attachment_thumbnail.php @@ -27,11 +27,7 @@ * @link http://status.net/ */ -if (!defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/actions/attachment.php'; +if (!defined('GNUSOCIAL') && !defined('STATUSNET')) { exit(1); } /** * Show notice attachments @@ -42,13 +38,21 @@ require_once INSTALLDIR.'/actions/attachment.php'; * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ - class Attachment_thumbnailAction extends AttachmentAction { + protected $thumb_w = null; // max width + protected $thumb_h = null; // max height + protected $thumb_c = null; // crop? - function handle($args) + protected function prepare(array $args=array()) { - $this->showPage(); + parent::prepare($args); + + $this->thumb_w = $this->int('w'); + $this->thumb_h = $this->int('h'); + $this->thumb_c = $this->boolean('c'); + + return true; } /** @@ -58,27 +62,8 @@ class Attachment_thumbnailAction extends AttachmentAction */ function showPage() { - if (Event::handle('StartShowBody', array($this))) { - $this->showCore(); - Event::handle('EndShowBody', array($this)); - } + // 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()); } - - /** - * Show core. - * - * Shows local navigation, content block and aside. - * - * @return nothing - */ - function showCore() - { - $file_thumbnail = File_thumbnail::staticGet('file_id', $this->attachment->id); - if (empty($file_thumbnail->url)) { - return; - } - $this->element('img', array('src' => $file_thumbnail->url, 'alt' => 'Thumbnail')); - } - } -