- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法在 Ionic 4 中显示 cdvphotolibrary://?
我已经尝试了大部分可用的方法来显示缩略图:
<allow-intent href="cdvphotolibrary:*" />
<allow-navigation href="cdvphotolibrary://*" />
<meta http-equiv="Content-Security-Policy" content="cdvphotolibrary:">
想法是显示这样的内容,缩略图实际上是图片库返回的:
cdvphotolibrary://thumbnail?photoId=43%3B%2Fstorage%2Femulated%2F0%2FDCIM%2FCamera%2F20190304_204426.jpg&width=512&height=384&quality=0.8
我正在使用 https://www.npmjs.com/package/cordova-plugin-photo-library
谢谢
最佳答案
好的,错误代码已经提供了更多信息。
It seems cdvphotolibrary://
协议(protocol)被归类为 file://
协议(protocol),您不能将它们用于较新的 webview。
但是,对于 file://协议(protocol)有一个解决方法:
这是:
For Cordova apps, the Ionic Web View plugin provides a utility function for converting File URIs: window.Ionic.WebView.convertFileSrc(). There is also a corresponding Ionic Native plugin: @ionic-native/ionic-webview.
而且似乎 file://urls are actually available通过插件:
this.photoLibrary
.requestAuthorization()
.then(() => {
this.photoLibrary
.getLibrary()
.subscribe({
next: library => {
library.forEach(libraryItem => {
let url: string;
if (libraryItem.id.split(';').length > 0) {
url = 'file://' + libraryItem.id.split(';')[1];
}
// Get http://localhost url
url = (window as any).Ionic.WebView.convertFileSrc(url)
});
},
error: err => {
console.log('could not get photos');
},
complete: () => {
console.log('done getting photos');
console.log(this.images);
count = 0;
},
});
})
.catch(err => {
console.log("permissions weren't granted");
});
然而,似乎 Ionic 可能需要做一些额外的调整 - 查看该线程以了解进一步的讨论。
关于ionic4 - cdvphotolibrary : display on IONIC 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57489377/
有没有办法在 Ionic 4 中显示 cdvphotolibrary://? 我已经尝试了大部分可用的方法来显示缩略图: 想法是显示这样的内容,缩略图实际上是图片库返回的: cdvphotoli
我是一名优秀的程序员,十分优秀!