Skip to content

Commit 50d3513

Browse files
Fix sizes icons (#725)
Co-authored-by: Gilles <[email protected]>
1 parent b0aa189 commit 50d3513

File tree

8 files changed

+83
-70
lines changed

8 files changed

+83
-70
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ All notable changes to this project will be documented in this file. For commit
1818
- admin special characters and general login improvements https://github.com/gtsteffaniak/filebrowser/issues/594
1919
- updated editor caching behavior https://github.com/gtsteffaniak/filebrowser/issues/701
2020
- move/copy file path issue and overwrite https://github.com/gtsteffaniak/filebrowser/issues/687
21+
- fix popup preview loading on safari
22+
- `preview.highQuality` only affects gallery view mode. popop preview is always high quality, and icons are always low quality.
2123

2224
## v0.7.6-beta
2325

backend/http/preview.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ func rawFileHandler(w http.ResponseWriter, r *http.Request, file iteminfo.Extend
9797

9898
func previewHelperFunc(w http.ResponseWriter, r *http.Request, d *requestContext) (int, error) {
9999
previewSize := r.URL.Query().Get("size")
100-
if !(previewSize == "small" || previewSize == "original") {
101-
previewSize = "large"
100+
if !(previewSize == "large" || previewSize == "original") {
101+
previewSize = "small"
102102
}
103103
if d.fileInfo.Type == "directory" {
104104
return http.StatusBadRequest, fmt.Errorf("can't create preview for directory")

frontend/src/api/files.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,10 @@ export function getDownloadURL(source, path, inline, useExternal) {
225225
}
226226
}
227227

228-
export function getPreviewURL(source, path, modified, selectedSize) {
229-
let size = state.user.preview.highQuality ? 'large' : 'small'
230-
if (selectedSize) {
231-
size = selectedSize
232-
}
228+
export function getPreviewURL(source, path, modified) {
233229
try {
234230
const params = {
235231
path: encodeURIComponent(path),
236-
size: size,
237232
key: Date.parse(modified), // Use modified date as cache key
238233
source: source,
239234
inline: 'true'

frontend/src/api/share.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { fetchURL, fetchJSON, adjustedData } from "./utils";
2-
import { state } from '@/store'
32
import { notify } from "@/notify";
43
import { getApiPath,removePrefix } from "@/utils/url.js";
54
import { externalUrl,baseURL } from "@/utils/constants";
@@ -54,7 +53,7 @@ export function getPreviewURL(hash, path) {
5453
try {
5554
const params = {
5655
path: encodeURIComponent(path),
57-
size: state.user.preview.highQuality ? 'large' : 'small',
56+
size: 'small',
5857
hash: hash,
5958
inline: 'true'
6059
}

frontend/src/components/files/Icon.vue

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
<template>
2-
<span v-if="isPreviewImg && imageState !== 'error'">
2+
<span
3+
@mouseenter="handleMouseEnter($event)"
4+
@mouseleave="handleMouseLeave($event)"
5+
v-if="isPreviewImg && imageState !== 'error'"
6+
>
37
<i
48
v-if="hasMotion"
59
class="material-icons"
610
:class="{ larger: showLarger, smaller: !showLarger }"
711
>animation</i
812
>
913
<img
10-
:key="thumbnailUrl"
14+
:key="imageTargetSrc"
1115
:src="imageDisplaySrc"
12-
@mouseenter="handleMouseEnter($event)"
13-
@mouseleave="handleMouseLeave($event)"
1416
class="icon"
1517
ref="thumbnail"
1618
/>
@@ -21,7 +23,12 @@
2123
</template>
2224

2325
<script>
24-
import { onlyOfficeUrl, mediaAvailable, muPdfAvailable, baseURL } from "@/utils/constants";
26+
import {
27+
onlyOfficeUrl,
28+
mediaAvailable,
29+
muPdfAvailable,
30+
baseURL,
31+
} from "@/utils/constants";
2532
import { getTypeInfo } from "@/utils/mimetype";
2633
import { mutations, state } from "@/store";
2734
@@ -56,10 +63,16 @@ export default {
5663
previewTimeouts: [],
5764
// UPDATED: Manage image state directly
5865
imageState: "loading", // Can be 'loading', 'loaded', or 'error'
59-
imageTargetSrc: this.thumbnailUrl, // The URL we currently want to display
6066
};
6167
},
6268
computed: {
69+
imageTargetSrc() {
70+
if (this.showLargeIcon) {
71+
// Use the large version of the thumbnail if available
72+
return this.thumbnailUrl + "&size=large" || PLACEHOLDER_URL;
73+
}
74+
return this.thumbnailUrl || PLACEHOLDER_URL;
75+
},
6376
pdfConvertable() {
6477
const ext = "." + this.filename.split(".").pop().toLowerCase(); // Ensure lowercase and dot
6578
const pdfConvertCompatibleFileExtensions = {
@@ -96,6 +109,9 @@ export default {
96109
}
97110
return this.imageTargetSrc;
98111
},
112+
showLargeIcon() {
113+
return state.user.viewMode === "gallery" && state.user.preview.highQuality;
114+
},
99115
showLarger() {
100116
return state.user.viewMode === "gallery" || state.user.viewMode === "normal";
101117
},
@@ -168,18 +184,19 @@ export default {
168184
targetImage.src = url;
169185
},
170186
handleMouseEnter() {
187+
const imageUrl = this.thumbnailUrl + "&size=large";
171188
if (this.imageState == "loaded") {
172-
mutations.setPreviewSource(this.thumbnailUrl);
189+
mutations.setPreviewSource(imageUrl);
173190
}
174191
if (!state.user.preview.motionVideoPreview || !this.hasMotion) {
175192
return;
176193
}
177194
178195
const sequence = [
179-
this.thumbnailUrl,
180-
this.thumbnailUrl + "&atPercentage=25",
181-
this.thumbnailUrl + "&atPercentage=50",
182-
this.thumbnailUrl + "&atPercentage=75",
196+
imageUrl,
197+
imageUrl + "&atPercentage=25",
198+
imageUrl + "&atPercentage=50",
199+
imageUrl + "&atPercentage=75",
183200
];
184201
let index = 0;
185202

frontend/src/i18n/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
"previewImages": "Preview images",
195195
"previewVideos": "Preview videos",
196196
"previewMotionVideos": "Motion preview for videos",
197-
"highQualityPreview": "High quality preview",
197+
"highQualityPreview": "High quality preview for gallery images",
198198
"editOffice": "Edit/view office files",
199199
"popupPreview": "Enable pop-up preview",
200200
"filePreviewOptions": "File preview options"

0 commit comments

Comments
 (0)