如何显示一把umbraco页面上有多个媒体选取图像与宏 [英] How to show umbraco multiple media picker images on page with a macro

查看:253
本文介绍了如何显示一把umbraco页面上有多个媒体选取图像与宏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好计算器人
希望你能帮助我,也许一个简单的问题,但无法在其他地方找到一个解决方案,我刚刚用一把umbraco现在的工作了一个星期,才使一切新的,我从来没有使用过MVC的一部分。

Hello stackoverflow people hope you can help me with maybe a simple question, but couldn't find a solution elsewhere and I have just been working with umbraco for a week now and have never used the mvc part before so all is new for me.

因此​​,最大的问题是如何使宏显示这些图片,我选择从多个媒体选取的宏应该只是表现结束了。

So the big problem is how I make a macro to show these images I choose from the multiple media picker the macro should just end with showing.

<img src="img1.gif" height="50" width="50">
<img src="img2.gif" height="50" width="50">

等等取决于有多少图像。 (大小只是一个exempel)

And so on depending on how many images there is. (the size is just an exempel)

我trye​​d财产以后这样的

I tryed somthing like this

 @var selectedMedia3 = @Library.MediaById(Model.mainImage);
      <img src="@selectedMedia3.umbracoFile" width="@selectedMedia3.umbracoWidth" height="@selectedMedia3.umbracoHeight" alt="@selectedMedia3.Name"/>                       
    }

但我不知道如何将图像的ID解析宏。
当我选择多个文件,我需要一个循环,但不知道如何循环的多个媒体选取的数据,因此即时通讯有点失去了现在。

But I dont know how to parse the id of the image to the macro. and when I choose more than one file I need a loop, but dont know how to loop the multiple media picker data, so im a little lost by now.

推荐答案

您可以让我们知道您正在使用什么版本的一把umbraco。一把umbraco已经通过一些在不同版本基波变化近年来不见了。下面code应该引导你在正确的方向一把umbraco 7多图片选择工具与propertyAlias​​ partnersLogos

Are you able to let us know what version of Umbraco you are using. Umbraco has gone through a number of fundemental changes in various version over recent years. The below code should guide you in the right direction for Umbraco 7 Multiple Image picker with the propertyAlias partnersLogos.

    @if (Model.Content.HasValue("partnersLogos"))
    {
        var partnersImagesList =  Model.Content.GetPropertyValue<string>("partnersLogos").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse);
        var partnersImagesCollection = Umbraco.TypedMedia(partnersImagesList).Where(x => x != null);
        foreach (var partnerImage in partnersImagesCollection)
        {
            <img src="@partnerImage.Url" alt="partners logo" />
        }
    }

这篇关于如何显示一把umbraco页面上有多个媒体选取图像与宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆