Handle missing userfiles more gracefully

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2023-02-02 10:49:36 -08:00
parent 2a8851bbd7
commit 78dca7fd32
2 changed files with 14 additions and 8 deletions

View file

@ -390,7 +390,8 @@ return [
'start_date' => 'Start Date', 'start_date' => 'Start Date',
'end_date' => 'End Date', 'end_date' => 'End Date',
'alt_uploaded_image_thumbnail' => 'Uploaded thumbnail', 'alt_uploaded_image_thumbnail' => 'Uploaded thumbnail',
'placeholder_kit' => 'Select a kit' 'placeholder_kit' => 'Select a kit',
'file_not_found' => 'File not found',

View file

@ -869,16 +869,19 @@
</td> </td>
<td> <td>
@if ($file->filename) @if ($file->filename)
@if ( Helper::checkUploadIsImage($file->get_src('users'))) @if ((Storage::exists('private_uploads/users/'.$file->filename)) && ( Helper::checkUploadIsImage($file->get_src('users'))))
<a href="{{ route('show/userfile', ['userId' => $user->id, 'fileId' => $file->id, 'download' => 'false']) }}" data-toggle="lightbox" data-type="image"><img src="{{ route('show/userfile', ['userId' => $user->id, 'fileId' => $file->id]) }}" class="img-thumbnail" style="max-width: 50px;"></a> <a href="{{ route('show/userfile', ['userId' => $user->id, 'fileId' => $file->id, 'download' => 'false']) }}" data-toggle="lightbox" data-type="image"><img src="{{ route('show/userfile', ['userId' => $user->id, 'fileId' => $file->id]) }}" class="img-thumbnail" style="max-width: 50px;"></a>
@else
<i class="fa fa-times text-danger" aria-hidden="true"></i>
{{ trans('general.file_not_found') }}
@endif @endif
@endif @endif
</td> </td>
<td> <td>
{{ $file->filename }} {{ $file->filename }}
</td> </td>
<td> <td data-value="{{ (Storage::exists('private_uploads/users/'.$file->filename)) ? Storage::size('private_uploads/users/'.$file->filename) : '' }}">
{{ Helper::formatFilesizeUnits(Storage::size('private_uploads/users/'.$file->filename)) }} {{ (Storage::exists('private_uploads/users/'.$file->filename)) ? Helper::formatFilesizeUnits(Storage::size('private_uploads/users/'.$file->filename)) : '' }}
</td> </td>
<td> <td>
@ -888,10 +891,12 @@
</td> </td>
<td> <td>
@if ($file->filename) @if ($file->filename)
<a href="{{ route('show/userfile', [$user->id, $file->id]) }}" class="btn btn-default"> @if ((Storage::exists('private_uploads/users/'.$file->filename)) && ( Helper::checkUploadIsImage($file->get_src('users'))))
<i class="fas fa-download" aria-hidden="true"></i> <a href="{{ route('show/userfile', [$user->id, $file->id]) }}" class="btn btn-default">
<span class="sr-only">{{ trans('general.download') }}</span> <i class="fas fa-download" aria-hidden="true"></i>
</a> <span class="sr-only">{{ trans('general.download') }}</span>
</a>
@endif
@endif @endif
</td> </td>
<td>{{ $file->created_at }}</td> <td>{{ $file->created_at }}</td>