简体   繁体   English

在 PowerApps 门户中显示 Dataverse 图像

[英]Displaying Dataverse images in PowerApps Portal

I'm trying to display the image attributes from Dataverse in the PowerApps Portal.我正在尝试在 PowerApps 门户中显示来自 Dataverse 的图像属性。 I know the documentation says that this isn't officially supported I've seen a few unofficial guides like https://www.itaintboring.com/powerapps/lets-show-an-image-on-the-power-apps-portal-form-too/ which seems promissing.我知道文档说这不是官方支持的-form -too/这似乎很有希望。

My only problem with that solution is that it requires hard-coded URL's in the Portal which doesn't work for us as we have a CD pipeline with multiple environments.我对该解决方案的唯一问题是它需要门户中的硬编码 URL,这对我们不起作用,因为我们有一个包含多个环境的 CD 管道。 Is there another way to do this?还有另一种方法可以做到这一点吗? Or can I somehow query for the URL instead of hardcoding it?或者我可以以某种方式查询 URL 而不是硬编码吗?

I don't have enough reputation to add a comment so I'm posting it as answer.我没有足够的声誉来添加评论,所以我将其发布为答案。

  1. you can retrieve the supporting image_url column value.您可以检索支持的 image_url 列值。 The URL is stored in supporting imageColumn_url column. URL 存储在支持的 imageColumn_url 列中。 Full URL should be something like this {organization_URL}/image/download.aspx?entity={table_name}&attribute={column_name}&id={entityImageId}&timestamp={image_timestamp} and can be used as src in img tag.完整的 URL 应该是这样的 {organization_URL}/image/download.aspx?entity={table_name}&attribute={column_name}&id={entityImageId}&timestamp={image_timestamp} 并且可以用作 img 标签中的 src。

  2. in the img tag set data-entityimage to be the image column.在 img 标签中设置 data-entityimage 为 image 列。 On window load convert entity image to base64 source.在 window 上加载将实体图像转换为 base64 源。

     <img data-entityimage="{{ imageColumn | join: ',' }}" />

    function toBase64(str) { if (;str) return null. function toBase64(str) { if (;str) 返回 null。 var uarr = new Uint8Array(str,split('.');map(function (x) { return parseInt(x); })). var uarr = new Uint8Array(str,split('.');map(function (x) { return parseInt(x); }))。 return btoa(String.fromCharCode,apply(null; uarr)); return btoa(String.fromCharCode,apply(null; uarr)); } }

     window.addEventListener('load', function () { document.querySelectorAll('img[data-entityimage]').forEach(function (img) { var data = img.dataset && img.dataset.entityimage; var base64data = data? toBase64(data): null; if (base64data) { img.src = 'data:image/jpeg;base64,' + base64data; } }); });

With (1) you are retrieving full sized image, and with (2) the thumbnail that is stored in cds使用 (1) 您正在检索全尺寸图像,使用 (2) 存储在 cds 中的缩略图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM