Skip to content

Commit

Permalink
feat: add fixed prop to specify fixed size images
Browse files Browse the repository at this point in the history
- This allow developers to pass width and height down through to the underlying element without imgix changing the image to a fixed size image
- This is important because new browser behaviour allows developers to use width/height to hint at the aspect ratio of the image
  • Loading branch information
frederickfogerty committed Jun 1, 2020
1 parent fd88d13 commit bba2b0b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/plugins/vue-imgix/ix-img.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
ensureVueImgixClientSingleton,
IVueImgixClient,
} from '@/plugins/vue-imgix/vue-imgix';
import { ensureVueImgixClientSingleton, IVueImgixClient } from '@/plugins/vue-imgix/vue-imgix';
import Vue, { CreateElement } from 'vue';
import Component from 'vue-class-component';

Expand All @@ -11,6 +8,7 @@ const IxImgProps = Vue.extend({
type: String,
required: true,
},
fixed: Boolean,
imgixParams: Object,
width: [String, Number],
height: [String, Number],
Expand All @@ -34,8 +32,10 @@ export class IxImg extends IxImgProps {

render(createElement: CreateElement) {
const imgixParamsFromImgAttributes = {
...(this.width != null ? { w: this.width } : {}),
...(this.height != null ? { h: this.height } : {}),
...(this.fixed && {
...(this.width != null ? { w: this.width } : {}),
...(this.height != null ? { h: this.height } : {}),
}),
};

const { src, srcset } = this.vueImgixSingleton.buildUrlObject(this.src, {
Expand Down

0 comments on commit bba2b0b

Please sign in to comment.