Skip to content

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

Merged
merged 1 commit into from
Aug 26, 2024
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.DS_Store
.AppleDouble
.LSOverride
.idea

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this line


# Thumbnails
._*
Expand Down
64 changes: 64 additions & 0 deletions src/developers/components/CloudinaryImage.vue
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<{
Copy link
Collaborator

Choose a reason for hiding this comment

The 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

const props = withDefaults(defineProps<{
  src: string
  alt: string
  width: number
  height: number
  quality?: string
  crop?: string
  faceRecognition?: boolean
  loading?: 'lazy' | 'eager'
  class?: string
  ....
}>(), {
  quality: 'q_auto:best',
  crop: 'c_fit',
  faceRecognition: false,
  class: '',
  ....
});

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commas

}>()

const cloudinaryUrl = 'https://res.cloudinary.com/proxify-io/image/upload'

Choose a reason for hiding this comment

The 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>
22 changes: 18 additions & 4 deletions src/developers/components/DeveloperCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { computed } from 'vue'
import { DeveloperProfile } from './type'
import { truncateTextFromArray } from './utils'
import { VTIconMapPin } from '@vue/theme'
import CloudinaryImage from './CloudinaryImage.vue'
import DeveloperProficiencies from './DeveloperProficiencies.vue'
import DeveloperCompensations from './DeveloperCompensations.vue'
import { useRouter } from 'vitepress'
Expand All @@ -16,8 +17,7 @@ const props = defineProps<{

const { id, alias, name, description, compensations, proficiencies, location } = props.data

const profileImage = computed(() => `/images/developers/${id}.jpg`)

const profileImage = computed(() => `/vue/developers/${id}.jpg`)
const trimmedDescription = computed(() => truncateTextFromArray(description, 220))

function openDeveloperPage() {
Expand All @@ -33,7 +33,16 @@ function openDeveloperPage() {
>
<div class="developer-card__header">
<div v-if="!hero && profileImage" class="developer-card__avatar">
<img :src="profileImage" :alt="name" />
<CloudinaryImage
:src="profileImage"
:alt="name"
:width="120"
:height="120"
:faceRecognition="true"
crop="c_fill"
loading="lazy"
class="avatar"
/>
</div>
<div class="developer-card__summary">
<h3 class="developer-card__name">{{ name }}</h3>
Expand Down Expand Up @@ -64,7 +73,12 @@ function openDeveloperPage() {
/>

<div v-if="hero && profileImage" class="developer-card__image">
<img :src="profileImage" :alt="name" />
<CloudinaryImage
:src="profileImage"
:alt="name"
:width="526"
:height="605"
/>
</div>
</div>
</template>
Expand Down
10 changes: 8 additions & 2 deletions src/developers/components/DeveloperPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import partnerConfig from '../partnerConfig.js'
import { DeveloperProfiles } from './type'
import { generateUTMUrl } from './utils'
import { VTIconChevronLeft, VTIconMapPin } from '@vue/theme'
import CloudinaryImage from './CloudinaryImage.vue'
import DeveloperCompensations from './DeveloperCompensations.vue'
import DeveloperProficiencies from './DeveloperProficiencies.vue'
import DeveloperProfileDiagram from './DeveloperProfileDiagram.vue'
Expand All @@ -24,7 +25,7 @@ const developer = (data as DeveloperProfiles).find(

const { id, name, location, description, compensations, proficiencies, experiences, education } = developer

const profileImage = computed(() => `/images/developers/${id}.jpg`)
const profileImage = computed(() => `/vue/developers/${id}.jpg`)

const route = useRoute()
const hireUsLink = computed(() => generateUTMUrl(partnerConfig.hireUsButtonUrl, route.path))
Expand All @@ -41,7 +42,12 @@ const hireUsLink = computed(() => generateUTMUrl(partnerConfig.hireUsButtonUrl,

<div class="developer-page__content">
<div v-if="profileImage" class="developer-page__profile-image">
<img :src="profileImage" :alt="name" />
<CloudinaryImage
:src="profileImage"
:alt="name"
:width="592"
:height="680"
/>
</div>

<div class="developer-page__main">
Expand Down
4 changes: 4 additions & 0 deletions src/developers/components/DeveloperPageFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ const { logo, partnerName } = partnerConfig
class="partner-footer__logo dark"
:alt="`${partnerName} logo`"
:src="getLogo(logo, true)"
width="135"
height="30"
/>
<img
class="partner-footer__logo"
:alt="`${partnerConfig.partnerName} logo`"
:src="getLogo(logo)"
width="135"
height="30"
/>
</a>

Expand Down
6 changes: 3 additions & 3 deletions src/developers/developers.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"MongoDB",
"Vue.js",
"Express.js",
"Node.js",
"Node.js",
"TypeScript",
"Nuxt.js",
"Laravel",
Expand Down Expand Up @@ -1246,7 +1246,7 @@
"Vagrant",
"Shopware",
"jQuery",
"Storybook",
"Storybook"
],
"compensations": {
"partTime": "€3,436 /month (20 h per week)",
Expand Down Expand Up @@ -1746,7 +1746,7 @@
"Vue.js",
"Vuex",
"Nuxt.js",
"Laravel",
"Laravel",
"Java",
"Tailwind",
"Jest",
Expand Down
Binary file removed src/public/images/developers/1020.jpg
Binary file not shown.
Binary file removed src/public/images/developers/1346.jpg
Binary file not shown.
Binary file removed src/public/images/developers/2535.jpg
Binary file not shown.
Binary file removed src/public/images/developers/3021.jpg
Binary file not shown.
Binary file removed src/public/images/developers/3709.jpg
Binary file not shown.
Binary file removed src/public/images/developers/4747.jpg
Binary file not shown.
Binary file removed src/public/images/developers/5022.jpg
Binary file not shown.
Binary file removed src/public/images/developers/5328.jpg
Binary file not shown.
Binary file removed src/public/images/developers/5486.jpg
Binary file not shown.
Binary file removed src/public/images/developers/5697.jpg
Binary file not shown.