Copied to clipboard

Flag this post as spam?

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


  • marcelodharma 6 posts 26 karma points
    May 25, 2012 @ 14:26
    marcelodharma
    0

    How to get the image from DAMP property?

    I know it´s a noob question. I´m new to Umbraco but i have searshed the forum but with no luck.

    I have this razor macro to write a piece of html.

    int contador 0;
      foreach(var item in Model.AncestorOrSelf(1).InicialPreLancamento)
      {
        contador++;
        var node Library.NodeById(item.InnerText);
        <li>
          <href="@node.Url">

    <img src="@node.Logo" alt="" />
            <img src="@node.ImagemGrande" alt="" />
            <h3>@node.Nome</h3>
            @node.DescricaoResumida
          </a>
        </li>
      }

    @node.Logo is an Upload data type and it works.

    @node.ImagemGrande is only on e DAMP image and I cant figure out how to make it work.

    Does anyone knows how to get this picture?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 25, 2012 @ 15:00
    Tom Fulton
    0

    Hi,

    Try @node.ImagemGrande[0].Image.umbracoFile

    Image being the media type of the media item which I'm assuming is Image unless you created a custom one.  The [0] is saying to get the first selected image since DAMP can have multiple images selected.

    -Tom

  • marcelodharma 6 posts 26 karma points
    May 25, 2012 @ 15:58
    marcelodharma
    0

    It return an error: 

    Error loading Razor Script pre-lancamento.cshtml
    'char' does not contain a definition for 'Image'


  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 25, 2012 @ 16:15
    Tom Fulton
    0

    In the properties of your DAMP datatype, are you storing the "Full Media XML" or "ID"?

    Guessing by that error message you are just storing the ID, in which case I think you can use:

    var myMedia = Library.MediaById(@node.ImagemGrande);
    <img src="@myMedia.umbracoFile" />

    -Tom 

  • marcelodharma 6 posts 26 karma points
    May 25, 2012 @ 16:29
    marcelodharma
    0

    Weird cuz it´s Full Media XML but it worked throught MediaByID

    Thank you very much. It solved the problem.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    May 25, 2012 @ 16:39
    Tom Fulton
    0

    Odd, maybe it was changed and the document needs to be resaved to store the full XML?

  • marcelodharma 6 posts 26 karma points
    May 25, 2012 @ 17:04
    marcelodharma
    0

    It´s XML. I changed a picture, saved  and it´s still showing the picture.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Oct 29, 2012 @ 11:00
    Jeroen Breuer
    0

    You can now use the DAMP Razor Model. It will always return the same objects so it doesn't matter if you store it as xml or id.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft