mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Removed requirement for matchign aspect ratio
refs https://github.com/TryGhost/Team/issues/1249 Based on design feedback so that users are able to use the card with less friciton.
This commit is contained in:
parent
1d19f74ba8
commit
804da37926
@ -129,24 +129,15 @@ export default class KoenigCardBeforeAfterComponent extends Component {
|
|||||||
|
|
||||||
@action
|
@action
|
||||||
uploadStart(file) {
|
uploadStart(file) {
|
||||||
// @TODO Handle in progress uploads
|
return new Promise((resolve) => {
|
||||||
let existingImage = this.args.payload.afterImage || this.args.payload.beforeImage;
|
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
let objectURL = URL.createObjectURL(file);
|
let objectURL = URL.createObjectURL(file);
|
||||||
let image = new Image();
|
let image = new Image();
|
||||||
image.addEventListener('load', () => {
|
image.addEventListener('load', () => {
|
||||||
let id = this.selectingFile;
|
let id = this.selectingFile;
|
||||||
this.selectingFile = false;
|
this.selectingFile = false;
|
||||||
let metadata = {
|
let metadata = {
|
||||||
aspectRatio: image.naturalWidth / image.naturalHeight,
|
|
||||||
id: id
|
id: id
|
||||||
};
|
};
|
||||||
if (existingImage) {
|
|
||||||
if (metadata.aspectRatio !== existingImage.aspectRatio) {
|
|
||||||
reject(new Error('Before/After images must have the same aspect ratio'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resolve(metadata);
|
resolve(metadata);
|
||||||
});
|
});
|
||||||
image.src = objectURL;
|
image.src = objectURL;
|
||||||
@ -159,7 +150,6 @@ export default class KoenigCardBeforeAfterComponent extends Component {
|
|||||||
image.addEventListener('load', () => {
|
image.addEventListener('load', () => {
|
||||||
let imageData = {
|
let imageData = {
|
||||||
src: file.url,
|
src: file.url,
|
||||||
aspectRatio: metadata.aspectRatio,
|
|
||||||
width: image.naturalWidth,
|
width: image.naturalWidth,
|
||||||
height: image.naturalHeight
|
height: image.naturalHeight
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user