Skip to content

Commit 2f24dc3

Browse files
authored
Merge pull request #2 from devforth/preview-width
feat: add maxListWidth and maxShowWidth options for preview image dim…
2 parents cdc1aee + baeb863 commit 2f24dc3

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

Diff for: custom/preview.vue

+9-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<script setup>
6262
import { ref, computed , onMounted, watch} from 'vue'
6363
import mediumZoom from 'medium-zoom'
64+
import { useRoute } from 'vue-router'
6465
6566
const img = ref(null);
6667
const zoom = ref(null);
@@ -71,12 +72,19 @@ const props = defineProps({
7172
meta: Object,
7273
})
7374
75+
const route = useRoute();
7476
const url = computed(() => {
7577
return props.record[`previewUrl_${props.meta.pluginInstanceId}`];
7678
});
7779
78-
const maxWidth = computed(() => props.meta.maxWidth ? { maxWidth: props.meta.maxWidth } : {});
80+
const maxWidth = computed(() => {
81+
const isShowPage = route.path.includes('/show/');
82+
const width = isShowPage
83+
? (props.meta.maxShowWidth || props.meta.maxWidth)
84+
: (props.meta.maxListWidth || props.meta.maxWidth);
7985
86+
return width ? { maxWidth: width } : {};
87+
});
8088
8189
// since we have no way to know the content type of the file, we will try to guess it from extension
8290
// for better experience probably we should check whether user saves content type in the database and use it here

Diff for: index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
127127
pathColumnLabel: resourceConfig.columns[pathColumnIndex].label,
128128
fieldsForContext: this.options.generation?.fieldsForContext,
129129
maxWidth: this.options.preview?.maxWidth,
130+
maxListWidth: this.options.preview?.maxListWidth,
131+
maxShowWidth: this.options.preview?.maxShowWidth,
130132
};
131133
// define components which will be imported from other components
132134
this.componentPath('imageGenerator.vue');

Diff for: types.ts

+10
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ export type PluginOptions = {
6969
*/
7070
maxWidth?: string,
7171

72+
/**
73+
* Maximum width of the preview image in list view
74+
*/
75+
maxListWidth?: string,
76+
77+
/**
78+
* Maximum width of the preview image in show view
79+
*/
80+
maxShowWidth?: string,
81+
7282
/**
7383
* Used to display preview (if it is image) in list and show views.
7484
* Defaulted to the AWS S3 presigned URL if resource is private or public URL if resource is public.

0 commit comments

Comments
 (0)