Hi guys
We got a customer, who wants to use the first image in the filefolder as the thumbnail, using the FilePublisher module.
How can we achive this?
The folders loop (Razor) dows not give a list of files.
Thanks :)
Hi guys
We got a customer, who wants to use the first image in the filefolder as the thumbnail, using the FilePublisher module.
How can we achive this?
The folders loop (Razor) dows not give a list of files.
Thanks :)
Anyone have an idea on how this can be achieved?
You have the path, so you can create a DirectoryInfo object with the path and load the first image using GetFiles('*.jpg') [0] or similar, and display that.
Thanks Nicolai, that did it.
I came up with this
@foreach (LoopItem folder in GetLoop("FoldersLoop")) { if (!string.IsNullOrEmpty(folder.GetString("FilepublishFileDatemodified"))) { DirectoryInfo di = new DirectoryInfo(HttpContext.Current.Server.MapPath(@folder.GetString("FilepublishFileLinkClean") + "/" + @folder.GetString("FilepublishFileName"))); var firstImage = "/Admin/Public/GetImage.ashx?crop=0&width=300&height=300&Compression=30&DoNotUpscale=false&FillCanvas=false&image=" + folder.GetString("FilepublishFileLinkClean") + "/" + folder.GetString("FilepublishFileName") + "/" + di.GetFiles("*")[0]; Match match = Regex.Match(folder.GetString("FilepublishFileIcon"), "src=\\\"(.*?)\\\""); <div class="grid__col-md-2 grid__col-sm-3 grid__col-xs-4 grid__col-6 grid--justify-space-between"> <a href="@folder.GetString("FilepublishFileLink")" class="filepublish__image-wrap"> <img src="@firstImage" class="filepublish__image grid--align-self-center" title="@folder.GetString("FilepublishFileName")" alt="@folder.GetString("FilepublishFileName")" /> </a> <div class="grid--justify-center filepublish__info"> <a href="@folder.GetString("FilepublishFileLink")" class="filepublish__name u-color-inherit" title="@folder.GetString("FilepublishFileName")">@folder.GetString("FilepublishFileName")</a> </div> </div> } else { <div class="grid__col-12"> <div class="grid__cell u-border-bottom u-border-top"> <a href="@folder.GetString("FilepublishFileLink")" title="@folder.GetString("FilepublishFileName")" class="btn btn--link btn--condensed dw-mod filepublish__back-btn u-no-margin"> <i class="fas fa-arrow-left"></i> @folder.GetString("FilepublishFileName") </a> </div> </div> } }
You must be logged in to post in the forum