feat: add new setting to control posts uploads being shown as thumbs

This commit is contained in:
Barış Soner Uşaklı
2025-10-21 10:11:18 -04:00
parent 93d46c842e
commit 97e59fbe04
4 changed files with 10 additions and 2 deletions

View File

@@ -38,6 +38,7 @@
"maximumTagLength": 15,
"undoTimeout": 0,
"allowTopicsThumbnail": 1,
"showPostUploadsAsThumbnails": 1,
"registrationType": "normal",
"registrationApprovalType": "normal",
"allowAccountDelete": 1,

View File

@@ -22,6 +22,7 @@
"reject-image-height": "Maximum Image Height (in pixels)",
"reject-image-height-help": "Images taller than this value will be rejected.",
"allow-topic-thumbnails": "Allow users to upload topic thumbnails",
"show-post-uploads-as-thumbnails": "Show post uploads as thumbnails",
"topic-thumb-size": "Topic Thumb Size",
"allowed-file-extensions": "Allowed File Extensions",
"allowed-file-extensions-help": "Enter comma-separated list of file extensions here (e.g. <code>pdf,xls,doc</code>). An empty list means all extensions are allowed.",

View File

@@ -33,8 +33,9 @@ Thumbs.load = async function (topicData) {
const topicsWithThumbs = topicData.filter((tid, idx) => hasThumbs[idx]);
const tidsWithThumbs = topicsWithThumbs.map(t => t.tid);
const thumbs = await loadFromTopicData(topicsWithThumbs);
const thumbs = await loadFromTopicData(topicsWithThumbs, {
thumbsOnly: meta.config.showPostUploadsAsThumbnails !== 1,
});
const tidToThumbs = _.zipObject(tidsWithThumbs, thumbs);
return topicData.map(t => (t && t.tid ? (tidToThumbs[t.tid] || []) : []));

View File

@@ -88,6 +88,11 @@
<label for="allowTopicsThumbnail" class="form-check-label">[[admin/settings/uploads:allow-topic-thumbnails]]</label>
</div>
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" id="showPostUploadsAsThumbnails" data-field="showPostUploadsAsThumbnails">
<label for="showPostUploadsAsThumbnails" class="form-check-label">[[admin/settings/uploads:show-post-uploads-as-thumbnails]]</label>
</div>
<div class="mb-3">
<label class="form-label" for="topicThumbSize">[[admin/settings/uploads:topic-thumb-size]]</label>
<input id="topicThumbSize" type="text" class="form-control" value="120" data-field="topicThumbSize">