-
Notifications
You must be signed in to change notification settings - Fork 0
get dev images optimized from cloudinary #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
.idea | ||
|
||
# Thumbnails | ||
._* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
|
||
const props = defineProps<{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @borna9II @29avet1 This is almost correct vue 3 syntax. If you want to add default values for the props we should use
I do not know it if we want to update this and also if PR to Vue is published. |
||
src: string, | ||
alt: string, | ||
width: number, | ||
height: number, | ||
quality?: { | ||
type: string, | ||
default: 'q_auto:best', | ||
}, | ||
crop?: { | ||
type: string, | ||
default: 'c_fit', | ||
}, | ||
faceRecognition?: { | ||
type: boolean, | ||
default: false, | ||
}, | ||
loading?: 'lazy' | 'eager', | ||
className?: { | ||
type: string, | ||
default: '', | ||
}, | ||
Comment on lines
+5
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove commas |
||
}>() | ||
|
||
const cloudinaryUrl = 'https://res.cloudinary.com/proxify-io/image/upload' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. move to config file |
||
|
||
const imageSrc = computed(() => { | ||
const attributes = [ | ||
'f_auto', | ||
'dpr_auto', | ||
props.crop, | ||
props.quality, | ||
props.faceRecognition ? 'g_face' : '', | ||
props.width ? `w_${props.width}` : '', | ||
props.height ? `h_${props.height}` : '', | ||
] | ||
.filter((item) => item !== '') | ||
.join(','); | ||
|
||
return `${cloudinaryUrl}/${attributes}/v1/${props.src.replace(/^\/+/, '')}`; | ||
}) | ||
</script> | ||
|
||
<template> | ||
<img | ||
:src="imageSrc" | ||
:alt="alt" | ||
:width="width" | ||
:height="height" | ||
:loading="loading" | ||
:class="['c-image', className]" | ||
/> | ||
</template> | ||
|
||
<style scoped> | ||
.c-image { | ||
max-width: 100%; | ||
height: auto; | ||
vertical-align: top; | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this line