Copied to clipboard

Flag this post as spam?

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


  • David Hyslop 24 posts 168 karma points
    Jul 26, 2016 @ 13:58
    David Hyslop
    0

    Archetype help

    Hi

    I'm using Archetype to display a row of images at the top of my site but am struggling getting the image URL out

    this is what I have

            @foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("featured"))
            {
       <div>
           @fieldset.GetValue("eventTitle")
            @fieldset.GetValue("eventLink")
            @fieldset.GetValue("eventImage")
    
    
            </div>
            }
    

    The @fieldset.GetValue("eventImage") is the problem I just get the image ID, does anyone know how I get the URL of the image.

    I'm Using Razor to do this.

    thanks.

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Jul 26, 2016 @ 14:15
    Dennis Aaen
    0

    Hi David,

    What if you do something like this would you then get the URL for the image.

    @fieldset.GetValue("eventImage").Url
    

    Hope this helps,

    /Dennis

  • David Hyslop 24 posts 168 karma points
    Jul 26, 2016 @ 14:30
    David Hyslop
    0

    Thanks Dennis

    I did try that but get this error.

    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments

    Source Error:

    Line 23: @fieldset.GetValue("eventTitle") Line 24: @fieldset.GetValue("eventLink") Line 25: @fieldset.GetValue("eventImage").Url Line 26:
    Line 27:

  • David Hyslop 24 posts 168 karma points
    Jul 27, 2016 @ 14:22
    David Hyslop
    100

    Just for info I managed to solve this by doing this.

                @foreach (var fieldset in Model.Content.GetPropertyValue<ArchetypeModel>("featured"))
                {
                    var eventImages = string.IsNullOrEmpty(@fieldset.GetValue("eventImage")) ? "" : Umbraco.Media(@fieldset.GetValue("eventImage")).Url; //blockImage
                    <div>
                        @fieldset.GetValue("eventTitle")
                        @fieldset.GetValue("eventLink")
    
                        <img src="@eventImages" class="img-responsive" />
    
    
                    </div>
                }
    

    Can't explain it as don't really understand it but found a few answers on another website and managed to combine a few other posts into this and it's now working as expected.

  • 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