Skip to content

Commit

Permalink
ensure none image files do not create thumbs and hide details in imag…
Browse files Browse the repository at this point in the history
…e directive
  • Loading branch information
nadar committed Sep 6, 2024
1 parent 65466ee commit 3adf8c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/apis/StorageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ public function actionImageInfo($id)
throw new NotFoundHttpException("Unable to find the given storage image.");
}

if (!$model->file->isImage) {
return $model->toArray(['id', 'source', 'file_id', 'filter_id', 'resolution_width', 'resolution_height', 'file'], ['source']);
}

// try to create thumbnail on view if not done
if (empty($model->tinyCropImage)) {
// there are very rare cases where the thumbnail does not exists, therefore generate the thumbnail and reload the model.
Expand Down
4 changes: 2 additions & 2 deletions src/views/layouts/_angulardirectives.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@
<div class="imageupload-preview" ng-show="imageinfo != null">
<div class="imageupload-preview-sizer"></div>
<img ng-src="{{thumb.source}}" ng-show="imageinfo != null" class="imageupload-preview-image" />
<div class="imageupload-infos">
<div class="imageupload-infos" ng-if="imageinfo != null && imageinfo.resolution_width && imageinfo.resolution_height">
<div class="imageupload-size" ng-show="!imageLoading">{{ imageinfo.resolution_width }} x {{ imageinfo.resolution_height }}</div>
</div>
</div>
<div class="imageupload-upload">
<storage-file-upload ng-model="fileId"></storage-file-upload>
</div>
<?php if (Yii::$app->adminuser->canRoute('admin/storage/index')): ?>
<div class="imageupload-filter" ng-show="!noFilters() && imageinfo != null">
<div class="imageupload-filter" ng-show="!noFilters() && imageinfo != null && imageinfo.resolution_width && imageinfo.resolution_height">
<select name="filterId" ng-model="filterId" ng-change="changeFilter()" convert-to-number>
<option value="0"><?= Admin::t('layout_no_filter'); ?></option>
<option ng-repeat="item in filtersData" value="{{ item.id }}">{{ item.name }} ({{ item.identifier }})</option>
Expand Down

0 comments on commit 3adf8c8

Please sign in to comment.