Skip to content
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
14 changes: 11 additions & 3 deletions custom/preview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
v-if="contentType && contentType.startsWith('image')"
:src="url"
class="rounded-md"
:style="maxWidth"
:style="[maxWidth, minWidth]"
ref="img"
data-zoomable
@click.stop="zoom.open()"
Expand Down Expand Up @@ -51,12 +51,12 @@
</style>

<style scoped>
img {
/* img {
min-width: 150px;
}
video {
min-width: 200px;
}
} */
</style>
<script setup>
import { ref, computed , onMounted, watch} from 'vue'
Expand Down Expand Up @@ -86,6 +86,14 @@ const maxWidth = computed(() => {
return width ? { maxWidth: width } : {};
});

const minWidth = computed(() => {
const isShowPage = route.path.includes('/show/');
const width = isShowPage
? (props.meta.minShowWidth || props.meta.minWidth)
: (props.meta.minListWidth || props.meta.minWidth);

return width ? { minWidth: width } : {};
});
// since we have no way to know the content type of the file, we will try to guess it from extension
// for better experience probably we should check whether user saves content type in the database and use it here
const contentType = computed(() => {
Expand Down
3 changes: 3 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
maxWidth: this.options.preview?.maxWidth,
maxListWidth: this.options.preview?.maxListWidth,
maxShowWidth: this.options.preview?.maxShowWidth,
minWidth: this.options.preview?.minWidth,
minListWidth: this.options.preview?.minListWidth,
minShowWidth: this.options.preview?.minShowWidth,
};
// define components which will be imported from other components
this.componentPath('imageGenerator.vue');
Expand Down
16 changes: 16 additions & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,22 @@ export type PluginOptions = {
* Maximum width of the preview image in show view
*/
maxShowWidth?: string,


/**
* Minimum width of the preview image
*/
minWidth?: string,

/**
* Minimum width of the preview image in list view
*/
minListWidth?: string,

/**
* Minimum width of the preview image in show view
*/
minShowWidth?: string,

/**
* Used to display preview (if it is image) in list and show views.
Expand Down