mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-06 15:15:55 +02:00
Fixed file form field failing resolution checks in certain circumstances
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
* Added missing closing </li> in language loops
|
||||
* Fixed issue with nested `list` fields both utilizing the custom `key` functionality
|
||||
* Fixed issue with `array` field nested in `list` that were losing their index order when the list reordered
|
||||
|
||||
* Fixed file form field failing resolution checks in certain circumstances
|
||||
|
||||
# v1.9.7
|
||||
## 06/21/2019
|
||||
|
||||
|
||||
@@ -77,27 +77,39 @@ const ACCEPT_FUNC = function(file, done, settings) {
|
||||
const resolution = settings.resolution;
|
||||
if (!resolution) return done();
|
||||
|
||||
setTimeout(() => {
|
||||
let error = '';
|
||||
if (resolution.min) {
|
||||
Object.keys(resolution.min).forEach((attr) => {
|
||||
if (resolution.min[attr] && file[attr] < resolution.min[attr]) {
|
||||
error += translations.PLUGIN_FORM.RESOLUTION_MIN.replace(/{{attr}}/g, attr).replace(/{{min}}/g, resolution.min[attr]);
|
||||
const reader = new FileReader();
|
||||
let error = '';
|
||||
if (resolution.min || (!(settings.resizeWidth || settings.resizeHeight) && resolution.max)) {
|
||||
reader.onload = function(event) {
|
||||
const image = new Image();
|
||||
image.src = event.target.result;
|
||||
image.onload = function() {
|
||||
if (resolution.min) {
|
||||
Object.keys(resolution.min).forEach((attr) => {
|
||||
if (resolution.min[attr] && this[attr] < resolution.min[attr]) {
|
||||
error += translations.PLUGIN_FORM.RESOLUTION_MIN.replace(/{{attr}}/g, attr).replace(/{{min}}/g, resolution.min[attr]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!(settings.resizeWidth || settings.resizeHeight)) {
|
||||
if (resolution.max) {
|
||||
Object.keys(resolution.max).forEach((attr) => {
|
||||
if (resolution.max[attr] && file[attr] > resolution.max[attr]) {
|
||||
error += translations.PLUGIN_FORM.RESOLUTION_MAX.replace(/{{attr}}/g, attr).replace(/{{max}}/g, resolution.max[attr]);
|
||||
if (!(settings.resizeWidth || settings.resizeHeight)) {
|
||||
if (resolution.max) {
|
||||
Object.keys(resolution.max).forEach((attr) => {
|
||||
if (resolution.max[attr] && this[attr] > resolution.max[attr]) {
|
||||
error += translations.PLUGIN_FORM.RESOLUTION_MAX.replace(/{{attr}}/g, attr).replace(/{{max}}/g, resolution.max[attr]);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return error ? done(error) : done();
|
||||
}, 50);
|
||||
}
|
||||
|
||||
done(error);
|
||||
};
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
} else {
|
||||
return done(error);
|
||||
}
|
||||
};
|
||||
|
||||
export default class FilesField {
|
||||
|
||||
2
themes/grav/css-compiled/template.css
vendored
2
themes/grav/css-compiled/template.css
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
20
themes/grav/js/admin.min.js
vendored
20
themes/grav/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user