Я не работал с Cordova, но документы, которые вы связали, говорят следующее:
Чтобы использовать cdvfile в качестве тега 'src, вы можете преобразовать его в собственный путь с помощью метода toURL () разрешенного fileEntry,который вы можете получить через resolLocalFileSystemURL - см. примеры ниже.
И приводит это в качестве примера:
resolveLocalFileSystemURL('cdvfile://localhost/temporary/path/to/file.mp4', function(entry) {
var nativePath = entry.toURL();
console.log('Native URI: ' + nativePath);
document.getElementById('video').src = nativePath;
Учитывая все это, я бы сказал, что вы можете попытаться создатькомпонент, cdv-img
.Что-то вроде этого должно работать, я думаю:
import Component from '@ember/component';
export default Component.extend({
tagName: 'img',
cdvPath: undefined,
didReceiveAttrs() {
this._super(...arguments);
if (this.cdvPath) {
resolveLocalFileSystemURL(this.cdvPath, (entry) => {
this.$().attr('src', entry.toURL());
});
}
},
});
Используйте это так:
{{cdv-img cdvPath='cdvfile://localhost/temporary/path/to/file.jpg'}}
UPD
Если это не работает с файловым протоколом, выможно попытаться преобразовать изображение в URL данных
import Component from '@ember/component';
export default Component.extend({
tagName: 'img',
cdvPath: undefined,
didReceiveAttrs() {
this._super(...arguments);
if (this.cdvPath) {
const el = this.$();
resolveLocalFileSystemURL(this.cdvPath, (entry) => {
entry.file(function (file) {
const reader = new FileReader();
reader.onloadend = function() {
el.attr('src', this.result);
};
reader.readAsDataURL(file);
});
});
}
},
});