【发布时间】:2020-08-10 20:00:00
【问题描述】:
我有一个脚本可以将图像上传到媒体库(工作正常),然后将每个图像分配给也可以工作的特定文档字段。唯一的问题是没有显示预览缩略图:
更新字段的代码非常简单:
private static void AssignImageToProject(string projectID, int index, string imgUrl)
{
var projectPage = _projectPages
.Where(p => p.GetStringValue("ProjectID", null) == projectID)
.FirstOrDefault();
if (projectPage == null) return;
projectPage.CheckOut();
projectPage.SetValue($"ProjectImage{index+1}", $"{imgUrl}");
// Updates the page in the database
projectPage.Update();
// Creates a new version of the updated page (required even when not using content locking)
// If using content locking, checks in the page
projectPage.CheckIn();
projectPage.Publish();
}
根据数据库,图像 url 是正确的,并且图像在前端按预期显示。有没有可以调用的方法来生成预览?
顺便说一下,我正在使用 Kentico 11。
编辑:在我的数据库中,字段值以 tilda '~' 开头,但正如您在屏幕截图中看到的那样,页面没有以 tilda 作为值的前缀。但是,如果我单击选择,它会将我带到正确的图像,如果我选择它,它会使用 tilda 更新字段并获得图像预览
【问题讨论】:
标签: kentico kentico-11