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
#763)

* ensure none image files do not create thumbs and hide details in image directive

* Apply php-cs-fixer changes

---------

Co-authored-by: nadar <nadar@users.noreply.github.com>
  • Loading branch information
nadar and nadar authored Sep 6, 2024
1 parent 65466ee commit e0a8e7c
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 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
1 change: 0 additions & 1 deletion tests/admin/ngrest/plugins/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use admintests\AdminTestCase;
use admintests\data\fixtures\UserFixture;

use luya\admin\ngrest\plugins\File;
use yii\base\Event;

Expand Down
1 change: 0 additions & 1 deletion tests/admin/ngrest/plugins/ImageArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace admintests\admin\ngrest\plugins;

use admintests\AdminTestCase;

use admintests\data\fixtures\UserFixture;
use luya\admin\ngrest\plugins\ImageArray;
use Yii;
Expand Down
1 change: 0 additions & 1 deletion tests/admin/ngrest/plugins/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace admintests\admin\ngrest\plugins;

use admintests\AdminTestCase;

use admintests\data\fixtures\UserFixture;
use luya\admin\ngrest\plugins\Image;
use yii\base\Event;
Expand Down
1 change: 0 additions & 1 deletion tests/admin/ngrest/plugins/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use admintests\AdminTestCase;
use admintests\data\fixtures\UserFixture;

use luya\admin\ngrest\plugins\Link;
use yii\base\Event;

Expand Down

0 comments on commit e0a8e7c

Please sign in to comment.