Skip to content

Commit

Permalink
thumbnail file generation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
brookgagnon committed Jun 30, 2024
1 parent 9b8fe85 commit 7ca56bd
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 25 deletions.
28 changes: 17 additions & 11 deletions models/media_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,6 @@ public function get_by_id($args = [])
$this->db->where('media.id', $args['id']);
$media = $this->db->get_one('media');

// DEPRECATED: Old media thumbnail code (interferes with new thumbnail items).
/* if ($media) {
$media['thumbnail'] = $this->models->media('media_thumbnail_exists', ['media' => $media]);
} */

return $media;
}

Expand All @@ -326,7 +321,7 @@ public function get_by_id($args = [])
*
* @param media ID or media row array.
*/
public function media_thumbnail_exists($args = [])
public function thumbnail_file($args = [])
{
OBFHelpers::require_args($args, ['media']);

Expand All @@ -350,7 +345,7 @@ public function media_thumbnail_exists($args = [])
mkdir($thumbnail_directory, 0755, true);
}

if ($media['type'] == 'image' && !file_exists($thumbnail_file)) {
if (($media['type'] == 'image' || $media['type'] == 'document') && !file_exists($thumbnail_file)) {
if ($media['is_archived'] == 1) {
$media_file = OB_MEDIA_ARCHIVE;
} elseif ($media['is_approved'] == 0) {
Expand All @@ -360,10 +355,21 @@ public function media_thumbnail_exists($args = [])
}
$media_file .= '/' . $media['file_location'][0] . '/' . $media['file_location'][1];
$media_file = $media_file . '/' . $media['filename'];
OBFHelpers::image_resize($media_file, $thumbnail_file, 600, 600);

if ($media['type'] == 'image') {
OBFHelpers::image_resize($media_file, $thumbnail_file, 600, 600);
}

if ($media['type'] == 'document') {
OBFHelpers::pdf_thumbnail($media_file, $thumbnail_file, 600, 600);
}
}

return file_exists($thumbnail_file);
if (file_exists($thumbnail_file)) {
return $thumbnail_file;
} else {
return false;
}
}

/**
Expand Down Expand Up @@ -763,7 +769,7 @@ public function search($args = [])

$items = $this->db->get('media');
foreach ($items as &$item) {
$item['thumbnail'] = $this->models->media('media_thumbnail_exists', ['media' => $item]);
$item['thumbnail'] = (bool) $this->models->media('thumbnail_file', ['media' => $item]);
$item['stream_thumbnail'] = file_exists(OB_CACHE . '/streams/' . $item['file_location'][0] . '/' . $item['file_location'][1] . '/' . $item['id'] . '/thumb.jpg');
}

Expand Down Expand Up @@ -801,7 +807,7 @@ public function search($args = [])

$items = $this->db->get('media');
foreach ($items as &$item) {
$item['thumbnail'] = $this->models->media('media_thumbnail_exists', ['media' => $item]);
$item['thumbnail'] = (bool) $this->models->media('thumbnail_file', ['media' => $item]);
$item['stream_thumbnail'] = file_exists(OB_CACHE . '/streams/' . $item['file_location'][0] . '/' . $item['file_location'][1] . '/' . $item['id'] . '/thumb.jpg');
}

Expand Down
3 changes: 3 additions & 0 deletions scss/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ body.sidebar-left #sidebar_search_playlist_footer .details
img
{
display: block;
width: 100%;
height: 100%;
object-fit: contain;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion themes/dark_on_light/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/dark_on_light/style.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/dark_on_light_hc/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/dark_on_light_hc/style.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/default/style.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion themes/default/style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion themes/light_on_dark_hc/style.css

Large diffs are not rendered by default.

Loading

0 comments on commit 7ca56bd

Please sign in to comment.