Skip to content

Commit a97db58

Browse files
committed
Add new custom Thumbnail component to display a preview of the image being edited in the drawer along with dimensions and file name metadata.
1 parent be13006 commit a97db58

File tree

7 files changed

+45
-11
lines changed

7 files changed

+45
-11
lines changed

classes/CheckFiles.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function findImagesWithoutContentOrTemplate(): array
3838
'blueprint' => $file->blueprint(),
3939
'mime' => $file->mime(),
4040
'thumbUrl' => $file->resize(300)->url(),
41+
'size' => $file->dimensions()->width() . ' x ' . $file->dimensions()->height() . ' px' ?? null,
4142
'parent' => $parent?->title()->value() ?? null,
4243
'parentId' => $file->parent()->id(),
4344
'fileUrl' => '/pages/' . $parentPanelUrl . '/files/' . $file->filename(),

index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
info: [
1818
'homepage' => 'https://github.com/scottboms/template-checker'
1919
],
20-
version: '1.1.1',
20+
version: '1.2.0',
2121
license: 'MIT',
2222
extends: [
2323
'options' => [],

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "template-checker",
33
"description": "Template Checker",
44
"author": "Scott Boms <[email protected]>",
5-
"version": "1.1.1",
5+
"version": "1.2.0",
66
"type": "kirby-plugin",
77
"license": "MIT",
88
"scripts": {

src/components/ImageList.vue

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@ export default {
107107
title: 'Quick Edit',
108108
icon: 'image',
109109
fields: {
110+
'preview': {
111+
'label': 'Preview',
112+
'type': 'thumbnail',
113+
'width': '1/1',
114+
'src': image.thumbUrl,
115+
'alt': image.alt || '',
116+
'size': image.size,
117+
'filename': image.filename
118+
},
110119
...(this.availableTemplates.length === 0
111120
? {
112121
'notice': {
@@ -130,20 +139,19 @@ export default {
130139
}
131140
}
132141
),
133-
'filename': {
134-
'label': 'File',
135-
'type': 'hidden',
136-
'text': `${image.id}`,
137-
'width': '1/1',
138-
},
139-
140142
'alt': {
141143
'label': 'Alt Text',
142144
'type': 'textarea',
143145
'buttons': false,
144146
'size': 'medium',
145147
'value': `${image.alt}`,
146-
'width': '1.1'
148+
'width': '1/1'
149+
},
150+
'filename': {
151+
'label': 'File',
152+
'type': 'hidden',
153+
'text': `${image.id}`,
154+
'width': '1/1',
147155
}
148156
},
149157
value: {

src/components/Thumbnail.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<k-field :label="label">
3+
<k-item
4+
:image="{ src: src }"
5+
:text="filename"
6+
:info="size"
7+
/>
8+
</k-field>
9+
</template>
10+
11+
<script>
12+
export default {
13+
props: {
14+
label: String,
15+
src: String,
16+
alt: String,
17+
filename: String,
18+
size: String
19+
}
20+
};
21+
</script>

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import ImageList from "./components/ImageList.vue";
2+
import Thumbnail from "./components/Thumbnail.vue";
23

34
panel.plugin("scottboms/template-checker", {
45
components: {
56
"k-image-template-checker": ImageList,
7+
},
8+
fields: {
9+
thumbnail: Thumbnail
610
}
711
});

0 commit comments

Comments
 (0)