Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jon 38 posts 157 karma points
    Jan 22, 2015 @ 02:48
    Jon
    0

    What is this type from a media picker?

    I get this type back when retreiving a value back from a media picker.

    Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache+DictionaryPublishedContent

    I can't seem to turn this into a useable Media item. Any idea how to achieve this?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 22, 2015 @ 05:18
    Jan Skovgaard
    0

    Hi Jon

    How are you trying to render the image? What does your current code look like? Do you mind sharing it? :)

    And what is the exact version of Umbraco 7?

    /Jan

  • Jon 38 posts 157 karma points
    Jan 22, 2015 @ 13:12
    Jon
    0

    Hi,

    I'm using Umbraco 7.2.1 and I also have the Umbraco Core Property Value Converters package installed, which seems like it might be relevant.

    Here's my code, edited down as it's part of a larger system but this is essentially the process:

    UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current);
    var settings = helper.TypedContent(settingsId);

    var logo = settings.GetPropertyValue("logo");

    //var logoMedia = Umbraco.TypedMedia(logo.Id.ToString()); // Value of Id visible in intellisense but marked as an error too. Also does this reload the item?

    logo is of type 'Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache+DictionaryPublishedContent'. I can see it's the correct item in intellisense but I can't find a way to turn it into a Media item that I can use.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 22, 2015 @ 14:22
    Jan Skovgaard
    0

    Hi Jon

    Have you tried just checking what the logo variable gives you if you just render it? @logo - I suspect that it just holds the id so you should be able to write var logoMedia = Umbraco.TypedMedia(logo.ToString());

    I'm asuming you're using a media picker somewhere and then the property should just hold the ID without you needing to write logo.Id.

    /Jan

  • Jon 38 posts 157 karma points
    Jan 22, 2015 @ 15:26
    Jon
    0

    This is what logo looks like.

    Sadly your piece of code doesn't work for me, logoMedia is null.

    I presume this is because I have the Umbraco Core Property Value Converters package installed.

  • Jon 38 posts 157 karma points
    Jan 22, 2015 @ 17:52
    Jon
    0

    But still, what is this type?

    I'd rather not uninstall the property value converters, it makes writing Razor code a lot cleaner and less faffy.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 22, 2015 @ 19:29
    Jan Skovgaard
    0

    Hi Jon

    Well when using the value converters the media picker should return IPublishedContent as it says on the package page.

    So what you're doing above seems right according to this https://our.umbraco.org/documentation/Reference/Mvc/querying (Don't mind that it says 4.10 - I don't think this has changed in v7).

    So do you get anything if you hardcode the id 1103? Just for testing if anything works at all?

    /Jan

  • Jon 38 posts 157 karma points
    Jan 23, 2015 @ 00:39
    Jon
    0

    Hi Jan,

    If I hardcode 1103 I get my Media back and I can use it as I'd expect.

    var logoMedia = Umbraco.TypedMedia(1103);

    I presume this is where you meant me to hard code it?

  • Jon 38 posts 157 karma points
    Jan 23, 2015 @ 17:18
    Jon
    1

    I don't suppose you've found any way to fix this? I'm a bit lost on what I can possibly do to fix it and it's currently a show stopper.

    Edit:

    Nevermind, I solved it by using this:

    IPublishedContent logo = UCore.Settings.GetPropertyValue<IPublishedContent>("logo");

    Pretty annoying - I /never/ use var and the one time that I do it all goes tits up!

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 23, 2015 @ 17:20
    Jan Skovgaard
    0

    Hi Jon

    No, unfortunately I don't have an idea about what could be the cause currently :-/

    /Jan

  • Jon 38 posts 157 karma points
    Jan 23, 2015 @ 17:30
    Jon
    0

    No worries Jan, see my edit above.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 23, 2015 @ 18:49
    Jan Skovgaard
    0

    Hi Jon

    Aaah, nice - Happy to see you got it all working and thanks for sharing so others can benefit :)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft