/** * Supplies a clean thumbnail URL for embedding an attachment on a board. * * @param \App\Board $board * @return string */ public function getThumbnailURL(Board $board) { $ext = $this->guessExtension(); if ($this->isSpoiler()) { return $board->getSpoilerUrl(); } if ($this->isImage() || $this->isDocument()) { $ext = Settings::get('attachmentThumbnailJpeg') ? "jpg" : "png"; } else { if ($this->isVideo()) { $ext = "jpg"; } else { if ($this->isAudio()) { if (!$this->hasThumb()) { return $board->getAudioArtURL(); } $ext = "png"; } else { if ($this->isImageVector()) { // With the SVG filetype, we do not generate a thumbnail, so just serve the actual SVG. return $this->getDownloadURL($board); } } } } $params = ['attachment' => $this->getIdentifier(), 'filename' => $this->getDownloadName() . ".{$ext}"]; if (!env('APP_MEDIA_URL', false)) { $params['board'] = $board; } // "False" generates a relativel URL. // Attachments get cached, so we want that. return route('static.thumb.attachment', $params, false); }
/** * Supplies a clean thumbnail URL for embedding an attachment on a board. * * @param App\Board $board * @return string */ public function getThumbnailURL(Board $board) { $baseURL = "/{$board->board_uri}/file/thumb/{$this->hash}/"; $ext = $this->guessExtension(); if ($this->isSpoiler()) { return $board->getSpoilerUrl(); } if ($this->isImage()) { $ext = Settings::get('attachmentThumbnailJpeg') ? "jpg" : "png"; } else { if ($this->isVideo()) { $ext = "jpg"; } else { if ($this->isAudio()) { if (!$this->hasThumb()) { return $board->getAudioArtURL(); } $ext = "png"; } else { if ($this->isImageVector()) { // With the SVG filetype, we do not generate a thumbnail, so just serve the actual SVG. $baseURL = "/{$board->board_uri}/file/{$this->hash}/"; } } } } return url("{$baseURL}{$this->getFileName()}.{$ext}"); }
/** * Supplies a clean thumbnail URL for embedding an attachment on a board. * * @param App\Board $board * @return string */ public function getThumbnailURL(Board $board) { $baseURL = "/{$board->board_uri}/file/thumb/{$this->hash}/"; $ext = $this->guessExtension(); if ($this->isSpoiler()) { return $board->getSpoilerUrl(); } if ($this->isAudio()) { if (!$this->hasThumb()) { return $board->getAudioArtURL(); } } else { if ($this->isImageVector()) { // With the SVG filetype, we do not generate a thumbnail, so just serve the actual SVG. $baseURL = "/{$board->board_uri}/file/{$this->hash}/"; } } // Sometimes we supply a filename when fetching the filestorage as an attachment. if (isset($this->pivot) && isset($this->pivot->filename)) { return url($baseURL . urlencode($this->pivot->filename)); } return url($baseURL . strtotime($this->first_uploaded_at) . "." . $this->guessExtension()); }