1
0
Fork 0
mirror of https://github.com/lrsjng/h5ai synced 2025-12-06 08:52:45 +01:00

Merge branch 'reduce_thumbnails' into PR_fix_short_video_thumbs

This commit is contained in:
glubsy 2021-01-25 21:45:32 +00:00
commit f5b540915b
2 changed files with 5 additions and 6 deletions

View file

@ -23,9 +23,6 @@ class Context {
$this->options = Json::load($this->setup->get('CONF_PATH') . '/options.json');
$this->thumbnail_height = $this->options['thumbnails']['size'] ?? 240;
$this->thumbnail_width = floor($this->thumbnail_height * (4 / 3));
$this->passhash = $this->query_option('passhash', '');
$this->options['hasCustomPasshash'] = strcasecmp($this->passhash, Context::$DEFAULT_PASSHASH) !== 0;
unset($this->options['passhash']);
@ -250,10 +247,12 @@ class Context {
public function get_thumbs($requests) {
$hrefs = [];
$height = $this->options['thumbnails']['size'] ?? 240;
$width = floor($this->thumbnail_height * (4 / 3));
foreach ($requests as $req) {
$thumb = new Thumb($this);
$hrefs[] = $thumb->thumb($req['type'], $req['href']);
$hrefs[] = $thumb->thumb($req['type'], $req['href'], $width, $height);
}
return $hrefs;

View file

@ -25,7 +25,7 @@ class Thumb {
}
}
public function thumb($type, $source_href) {
public function thumb($type, $source_href, $width, $height) {
$source_path = $this->context->to_path($source_href);
if (!file_exists($source_path) || Util::starts_with($source_path, $this->setup->get('CACHE_PUB_PATH'))) {
return null;
@ -49,7 +49,7 @@ class Thumb {
$capture_path = $source_path;
}
return $this->thumb_href($capture_path, $this->context->thumbnail_width, $this->context->thumbnail_height);
return $this->thumb_href($capture_path, $width, $height);
}
private function thumb_href($source_path, $width, $height) {