LIL-588 При создании курса висит браузер из-за загрузки больших фотографий

remotes/origin/hotfix/LIL-661
gzbender 8 years ago
parent a0a4b0b059
commit a9ce19e2bb
  1. 4
      web/package.json
  2. 25
      web/src/components/blocks/Image.vue

@ -34,9 +34,13 @@
"webpack": "^3.10.0" "webpack": "^3.10.0"
}, },
"dependencies": { "dependencies": {
"autosize": "^4.0.2",
"autosize-input": "^1.0.2",
"axios": "^0.17.1", "axios": "^0.17.1",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"baguettebox.js": "^1.10.0", "baguettebox.js": "^1.10.0",
"downscale": "^1.0.4",
"glob": "^7.1.2",
"history": "^4.7.2", "history": "^4.7.2",
"ilyabirman-likely": "^2.3.0", "ilyabirman-likely": "^2.3.0",
"inputmask": "^3.3.11", "inputmask": "^3.3.11",

@ -10,6 +10,7 @@
<script> <script>
import {api} from "../../js/modules/api"; import {api} from "../../js/modules/api";
import downscale from 'downscale';
export default { export default {
name: "lil-image", name: "lil-image",
@ -25,16 +26,18 @@
let file = event.target.files[0]; let file = event.target.files[0];
let reader = new FileReader(); let reader = new FileReader();
reader.onload = () => { reader.onload = () => {
api.uploadImage(reader.result, this.accessToken) downscale(reader.result, 2000, 2000).then((dataURL) => {
.then((response) => { api.uploadImage(dataURL, this.accessToken)
this.loading = false; .then((response) => {
this.$emit('update:imageId', response.data.id); this.loading = false;
this.$emit('update:imageUrl', response.data.image); this.$emit('update:imageId', response.data.id);
}) this.$emit('update:imageUrl', response.data.image);
.catch((error) => { })
this.loading = false; .catch((error) => {
console.log('error', error); this.loading = false;
}); console.log('error', error);
});
});
}; };
if (file) { if (file) {
reader.readAsDataURL(file); reader.readAsDataURL(file);
@ -51,4 +54,4 @@
display: block; display: block;
object-fit: contain; object-fit: contain;
} }
</style> </style>

Loading…
Cancel
Save