Skip to content

Commit

Permalink
[fix] use a workaround to avoid the issue in which width and height s…
Browse files Browse the repository at this point in the history
…et by modifiders turn to undefined in the provider
  • Loading branch information
anton-karlovskiy committed Jan 26, 2021
1 parent 996e898 commit d66ae7a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
11 changes: 4 additions & 7 deletions components/Images.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,10 @@ export default {
methods: {
handleData() {
for (const image of this.images) {
image.thumb = this.$img(image.file_path, {
modifiers: {
width: this.type === 'poster' ? 370 : 533,
height: this.type === 'poster' ? 556 : 300
}
}).url;
image.src = this.$img(image.file_path).url;
image.thumbSrc = image.file_path;
image.thumbWidth = this.type === 'poster' ? 370 : 533;
image.thumbHeight = this.type === 'poster' ? 556 : 300;
image.src = image.file_path;
}
},
Expand Down
8 changes: 5 additions & 3 deletions components/ImagesItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
<template>
<div :class="[$style.item, $style[type]]">
<a
:href="image.thumb"
:href="image.thumbSrc"
@click.prevent="handleGallery(index)">
<div :class="$style.image">
<nuxt-img
v-if="image.thumb"
v-if="image.thumbSrc"
loading="lazy"
:src="image.thumb" />
:src="image.thumbSrc"
:width="image.thumbWidth"
:height="image.thumbHeight" />
</div>
</a>
</div>
Expand Down
1 change: 0 additions & 1 deletion utils/tmdb-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { joinURL } from 'ufo';
import { TMDB_IMAGE_URL } from '~/config/tmdbAPI';

// RE: https://image.nuxtjs.org/advanced/custom-provider

function getImage(src, { modifiers = {} } = {}) {
const { width, height } = modifiers;

Expand Down

0 comments on commit d66ae7a

Please sign in to comment.