Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure none image files do not create thumbs and hide details in imag… #763

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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