lemunk
lemunk

Reputation: 2636

umbraco 7.1 recursive image

using MS visual studio 2012, c# 4.5 and Umbraco 7.1.

I have been tweaking my master page, and I noticed I had to make images recursive (display on every page).

with property's its no problem, you simply say for example:

@Umbraco.Field("pageTitle", recursive: true)

this works fine, however for images its a little different as im using a media picker as the datatype for the image, when you do this you need to add some extra code like the following

if (Model.Content.HasValue("titleImage"))
{
    var dynamicMedia1 = Umbraco.Media(Model.Content.GetPropertyValue("titleImage"));
    <a class="pull-left">
        <img class="media-object" src="@dynamicMedia1.umbracoFile" alt="" />
    </a>
}

this display the image correctly which is great, but as it does not use umbraco.field I cant see how to use "recursive". I've tried looking at some old documentation but doesn't really reference images. And as most will know the new info Isn't quiet available + from what I found there was no mention of recursive images.

Is this possible? Am I missing something?

cheers guys

Upvotes: 0

Views: 1564

Answers (2)

Misbit
Misbit

Reputation: 347

You can also use Model.Content.HasValue("logotype", true) where "true" is the value of a boolean that sets the property's recursiveness. Set to "false" it will look for the property on the current page.

Upvotes: 0

lemunk
lemunk

Reputation: 2636

For anyone interested,

seems as the though all you need to do is add and underscore on the name, this flags the image as recursive.

.... Model.Content.GetPropertyValue("_titleImage")

Upvotes: 1

Related Questions