Files
test/jikimo_frontend/static/src/js/custom_image.js

32 lines
1.2 KiB
JavaScript

/** @odoo-module **/
import {patch} from '@web/core/utils/patch';
import { url } from "@web/core/utils/urls";
import { ImageField, imageCacheKey } from '@web/views/fields/image/image_field';
patch(ImageField.prototype, 'jikimo_frontend/static/src/js/custom_image.js', {
// 你可以重写或者添加一些方法和属性
getUrl(previewFieldName) {
console.log('666666666666666666666666666666666')
if (this.state.isValid && this.props.value) {
if (1) {
if (!this.rawCacheKey) {
this.rawCacheKey = this.props.record.data.__last_update;
}
return url("/web/image", {
model: this.props.record.resModel,
id: this.props.record.resId,
field: previewFieldName,
unique: imageCacheKey(this.rawCacheKey),
});
} else {
// Use magic-word technique for detecting image type
const magic = fileTypeMagicWordMap[this.props.value[0]] || "png";
return `data:image/${magic};base64,${this.props.value}`;
}
}
return placeholder;
}
}
);