不能得到的图像中Umbraco7显示剃刀 [英] Cant get the image to show in Umbraco7 with razor

查看:93
本文介绍了不能得到的图像中Umbraco7显示剃刀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用了媒体选取作为类型,其用户要选择自己想要的图像处理什么样的形象的数据类型。

但由于某些原因,我不能让剃刀语法来显示图像。如果我做检查的if语句,如果页面包含一个图像,然后它不会。我认为这是发生因为我有一些误解的问题。

我现在的剃须刀语句:

 < IMG SRC =@ Umbraco.TypedMedia(Model.Content.GetPropertyValue(deal1image)。)网址/>

以上code将不会显示任何东西。

希望任何你能指导我我做什么错了,EVT。东西我错过了。

这是我目前的home.cshtml的样子:

  @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@ {
    布局=Master.cshtml;
}
< D​​IV CLASS =容器>
    < D​​IV CLASS =COL-MD-4>
        <! - 图片在这里 - >
        &所述; IMG SRC =@ Umbraco.Media(CurrentPage.deal1image).URL/>
        < D​​IV CLASS =缩略图thumbnailcustom thumbnailbg1>
            < H3> @ Umbraco.Field(dealtitle1)< / H3 GT&;
            &所述p为H.; @ Umbraco.Field(dealdescription1)&所述; / P>
        < / DIV>
    < / DIV>
    < D​​IV CLASS =COL-MD-4>
        <! - 图片在这里 - >
        < D​​IV CLASS =缩略图thumbnailcustom thumbnailbg2>
            < H3> @ Umbraco.Field(dealtitle2)< / H3 GT&;
            &所述p为H.; @ Umbraco.Field(dealdescription2)&所述; / P>
        < / DIV>
    < / DIV>
    < D​​IV CLASS =COL-MD-4>
        <! - 图片在这里 - >
        < D​​IV CLASS =缩略图thumbnailcustom thumbnailbg3>
            < H3> @ Umbraco.Field(dealtitle3)< / H3 GT&;
            &所述p为H.; @ Umbraco.Field(dealdescription3)&所述; / P>
        < / DIV>
    < / DIV>
< / DIV>


解决方案

使用Umbraco.Media的一个例子:

  VAR MYPAGE = CurrentPage.AncestorsOrSelf(),其中(DocumentTypeAlias​​ == @ 0,yourPageAlias​​)第一()。Umbraco.Media(myPage.myImage.ToString())。网址

I have used the media picker as data type for the type, for which the user is going to choose what image they want as the deal image.

But for some reason i can't get the razor syntax to show the image. If I make an If statement to check if the page contains an image then it won't. I think this is a problem that occurs because i have misunderstood something.

My current razor statement:

<img src="@Umbraco.TypedMedia(Model.Content.GetPropertyValue("deal1image")).Url" />

The above code won't show anything.

Hope any of you can guide me to what i do wrong and evt. stuff I'm missing.

This is how my current home.cshtml looks like:

 @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
    Layout = "Master.cshtml";
}
<div class="container">
    <div class="col-md-4">
        <!--Image here-->
        <img src="@Umbraco.Media(CurrentPage.deal1image).Url" />


        <div class="thumbnail thumbnailcustom thumbnailbg1">
            <h3>@Umbraco.Field("dealtitle1")</h3>
            <p>@Umbraco.Field("dealdescription1")</p>
        </div>
    </div>
    <div class="col-md-4">
        <!--Image here-->
        <div class="thumbnail thumbnailcustom thumbnailbg2">
            <h3>@Umbraco.Field("dealtitle2")</h3>
            <p>@Umbraco.Field("dealdescription2")</p>
        </div>
    </div>
    <div class="col-md-4">
        <!--Image here-->
        <div class="thumbnail thumbnailcustom thumbnailbg3">
            <h3>@Umbraco.Field("dealtitle3")</h3>
            <p>@Umbraco.Field("dealdescription3")</p>
        </div>
    </div>
</div>

解决方案

An example of using Umbraco.Media:

var myPage = CurrentPage.AncestorsOrSelf().Where("DocumentTypeAlias == @0", "yourPageAlias").First();

Umbraco.Media(myPage.myImage.ToString()).Url

这篇关于不能得到的图像中Umbraco7显示剃刀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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