Skip to content

Commit

Permalink
Merge pull request #32 from catalyst/debugging-fix
Browse files Browse the repository at this point in the history
Issue #31: Handle missing files better
  • Loading branch information
Peterburnett authored Jan 27, 2022
2 parents f14204d + 5ce327c commit af66c00
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion block_carousel.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function get_content() {
if ($slides > 1) {
$firstslide = reset($data);
$height = $firstslide['heightres'];
if ($height === 0) {
if (empty($height)) {
$ratio = 1;
} else {
$ratio = ($firstslide['widthres'] / $firstslide['heightres']);
Expand All @@ -143,6 +143,11 @@ public function get_content() {
continue;
}

// Filter any files that are not present or broken.
if (is_null($data->heightres) && is_null($data->widthres) && $data->contenttype === 'image') {
continue;
}

// Check release timing.
if ((!empty($data->timedstart) && time() < $data->timedstart) ||
(!empty($data->timedend) && time() > $data->timedend)) {
Expand Down
9 changes: 7 additions & 2 deletions classes/cache/slide_cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,13 @@ public function load_for_cache($key) {
$data['widthres'] = 0;
} else if ($record->contenttype === 'image') {
$imageinfo = $selectedfile->get_imageinfo();
$data['heightres'] = $imageinfo['height'];
$data['widthres'] = $imageinfo['width'];
if (!$imageinfo) {
$data['heightres'] = null;
$data['widthres'] = null;
} else {
$data['heightres'] = $imageinfo['height'];
$data['widthres'] = $imageinfo['width'];
}
} else {
// Use FFMpeg to get resolution.
$path = $selectedfile->copy_content_to_temp();
Expand Down

0 comments on commit af66c00

Please sign in to comment.