Skip to content

Commit

Permalink
Merge branch 'reduce_thumbnails' into PR_fix_short_video_thumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
glubsy committed Jan 23, 2021
2 parents 8280aff + 3756441 commit 204838e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/_h5ai/private/conf/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
- mov: array of strings
- doc: array of strings
- delay: number, delay in milliseconds after "dom-ready" before thumb-requesting starts
- size: number, size in pixel of the generated thumbnails
- size: number, height in pixel of the generated thumbnails
- seek: number, percentage of total video duration to seek into
- exif: boolean, use included EXIF thumbs if possible
- chunksize: int, number of thumbs per request
Expand Down
5 changes: 4 additions & 1 deletion src/_h5ai/private/php/core/class-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public function __construct($session, $request, $setup) {

$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']);
Expand Down Expand Up @@ -240,7 +243,7 @@ public function get_thumbs($requests) {

foreach ($requests as $req) {
$thumb = new Thumb($this);
$hrefs[] = $thumb->thumb($req['type'], $req['href'], $req['width'], $req['height']);
$hrefs[] = $thumb->thumb($req['type'], $req['href']);
}

return $hrefs;
Expand Down
4 changes: 2 additions & 2 deletions src/_h5ai/private/php/ext/class-thumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct($context) {
}
}

public function thumb($type, $source_href, $width, $height) {
public function thumb($type, $source_href) {
$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;
Expand All @@ -49,7 +49,7 @@ public function thumb($type, $source_href, $width, $height) {
$capture_path = $source_path;
}

return $this->thumb_href($capture_path, $width, $height);
return $this->thumb_href($capture_path, $this->context->thumbnail_width, $this->context->thumbnail_height);
}

private function thumb_href($source_path, $width, $height) {
Expand Down
2 changes: 2 additions & 0 deletions src/_h5ai/public/css/lib/view/view.less
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
.thumb {
max-width: none;
max-height: none;
object-fit: cover;
object-position: 50% 50%;
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/_h5ai/public/js/lib/ext/thumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const settings = Object.assign({
exif: false,
chunksize: 20
}, allsettings.thumbnails);
const landscapeRatio = 4 / 3;


const queueItem = (queue, item) => {
Expand All @@ -35,7 +34,6 @@ const queueItem = (queue, item) => {
queue.push({
type,
href: item.absHref,
ratio: 1,
callback: src => {
if (src && item.$view) {
item.thumbSquare = src;
Expand All @@ -51,7 +49,6 @@ const queueItem = (queue, item) => {
queue.push({
type,
href: item.absHref,
ratio: landscapeRatio,
callback: src => {
if (src && item.$view) {
item.thumbRational = src;
Expand All @@ -67,8 +64,6 @@ const requestQueue = queue => {
return {
type: req.type,
href: req.href,
width: Math.round(settings.size * req.ratio),
height: settings.size
};
});

Expand Down

0 comments on commit 204838e

Please sign in to comment.