Copied to clipboard

Flag this post as spam?

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


  • Vanilson 28 posts 150 karma points
    May 06, 2016 @ 18:04
    Vanilson
    0

    Getting a Image from Extended Media Picker

    Hi guys, I´m new in Umbraco and I´m having problems with getting a imagem from Extended Media Picker. Here is the code that I´m using:

    @foreach (var project in listOfProjects)
    {
              var projectImage= Umbraco.Media(project .imageProject);
              <img class="img-responsive" src="@projectImage.umbracofile" alt="thumb" />
    
    }
    

    The code it´s returning me a json in the src atribute.

    enter image description here

    Anyone knows how to solve this problem?

    Best Regards

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 07, 2016 @ 08:36
    Dennis Aaen
    0

    Hi Vanilson and welcome to our :)

    Try to use this code below, as you can see I have removed the spacing between project .imageProject and added uppercase F in umbracoFile.

    @foreach (var project in listOfProjects)
    {
              var projectImage = Umbraco.Media(project.imageProject);
              <img class="img-responsive" src="@projectImage.umbracoFile" alt="thumb" />
    
    }
    

    Hope this helps,

    /Dennis

  • Vanilson 28 posts 150 karma points
    May 07, 2016 @ 08:48
    Vanilson
    0

    Hi Dennis, thank you for the reply. I make the changes and still not working.

    Best Regards

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 07, 2016 @ 09:10
    Dennis Aaen
    0

    Hi Vanilson,

    When you are saying that you are using Extended Media Picker then we are talking about this package https://our.umbraco.org/projects/backoffice-extensions/extended-media-picker/ ?

    Have you checked that you are using the right properyAlias from the document type, and the node has a picture assigned.

    If you could share you full code then I think, it easier to help, or perhaps some screenshots of your content structure.

    /Dennis

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    May 07, 2016 @ 09:28
    Dennis Aaen
    100

    Hi Vanilson,

    Okay I have tested a bit more when you have more than one image added to the picker, there was a problem.

    But you can solve this by using and customize the code that you can find here so it match your case

    https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/media-picker

    @foreach (var project in listOfProjects){
         var projectImagesList = project.projectImage.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
         var projectImagesCollection = Umbraco.Media(projectImagesList);
    
             foreach (var peojctImageImage in projectImagesCollection){
                  <img class="img-responsive" src="@peojctImageImage.Url" alt="thub"/>
             }
    
    }
    

    I have updated the code snippet so it should work with your setup

    Hope this helps,

    /Dennis

  • Vanilson 28 posts 150 karma points
    May 09, 2016 @ 18:42
    Vanilson
    0

    Hi Dennis, it works, I just changed this line:

     var projectImagesList = project.projectImage.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
    

    to this:

     var projectImagesList = project.projectImage.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
    

    Thank you and best regards

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies