Copied to clipboard

Flag this post as spam?

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


  • Sebastian Dammark 581 posts 1405 karma points
    Aug 28, 2014 @ 23:03
    Sebastian Dammark
    0

    No image output

    In spite of following Jeavon's nice uHangout I can't get an Image output with Razor.

    This is my code:

    @{
        if (CurrentPage.HasValue("generel_image")) {
            var image = Umbraco.Media(CurrentPage.generel_image);
            <img src='@image.GetCropUrl("Standard")' />
        }
    }

    On the doument I have a Media picker and on the Media I swapped the Upload with the Cropper.

    What am I doing wrong here ?  I don't get any errors.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 28, 2014 @ 23:51
    Dennis Aaen
    0

    Hi Sebastian,

    Maybe a stupid question, but are you sure that the CurrentPage has an image assigned and the generel_image is not empty for the page that you are on. It just to be sure ;-)

    @{
        if(CurrentPage.HasValue("generel_image")){
            var image = Umbraco.Media(CurrentPage.generel_image);
            <img src='@image.GetCropUrl("standard")'/>
        }
    }

    Does it any different if you try the typed version? Something like this:

    @{
        if (CurrentPage.HasValue("generel_image")){
            var image = Umbraco.TypedMedia((int)CurrentPage.generel_image);
                <a href="@CurrentPage.Url" class="image image-full">
                    <img src='@image.GetCropUrl("standard")' alt="" />
                </a>
            }
        }
    }

    Hope this helps,

    /Dennis

  • Sebastian Dammark 581 posts 1405 karma points
    Aug 29, 2014 @ 10:26
    Sebastian Dammark
    0

    Well, if I try to render generel_media with GetMedia in XSLT i get this:

    <textarea>
    <xsl:copy-of select="umb:GetMedia($currentPage/generel_media, 0)" />
    </textarea>
    <Image id="1238" parentID="1085" level="2" creatorID="2" sortOrder="1" createDate="2014-08-28T22:22:00" updateDate="2014-08-28T22:22:16" nodeName="_DSC7830.jpg" urlName="_dsc7830jpg" path="-1,1085,1238" isDoc="" nodeType="1032" writerName="Sebastian Dammark" writerID="2" version="3d8d07df-f1c4-4ef5-b758-15bae4fea6cc" template="0" nodeTypeAlias="Image"><umbracoWidth>1618</umbracoWidth><umbracoHeight>1080</umbracoHeight><umbracoBytes>854554</umbracoBytes><umbracoExtension>jpg</umbracoExtension><umbracoFile>/media/1021/_dsc7830.jpg</umbracoFile></Image>

    And if I add @CurrentPage.HasValue("generel_image") it gives me False.

  • Jeavon Leopold 3073 posts 13630 karma points MVP 11x admin c-trib
    Aug 29, 2014 @ 11:07
    Jeavon Leopold
    0

    Hi Sebastian,

    After changing from uplaod to image cropper, can you please try to edit and save the media item?

    Also could you please try the below to see what result you get and post the result?

    @{
        foreach (var prop in Model.Content.Properties)
        {
            <p>@prop.PropertyTypeAlias</p>
            <pre>@prop.DataValue</pre>
        }
    }
    

    Jeavon

  • Mads Krohn 211 posts 504 karma points c-trib
    Aug 29, 2014 @ 11:20
    Mads Krohn
    3

    Is it a copy paste error that the value in xslt is generel_media and in razor it's generel_image ?
    Spelled general btw ? :D

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Aug 29, 2014 @ 11:22
    Dennis Aaen
    100

    Hi Sebastian,

    One thing that I have noticed is when you are trying to get the image in XSLT you´re using generel_media as propertyAlias

    When you are do it In Razor you are using the generel_image as propertyAlias

    <textarea>
    <xsl:copy-of select="umb:GetMedia($currentPage/generel_media, 0)" />
    </textarea>
    @CurrentPage.HasValue("generel_image")

    Should it not be generel_media like this instead of generel_image

    @CurrentPage.HasValue("generel_media")

    Hope this helps,

    /Dennis

  • Sebastian Dammark 581 posts 1405 karma points
    Aug 29, 2014 @ 11:26
    Sebastian Dammark
    0

    Thanx alot.  That was the problem :)

Please Sign in or register to post replies

Write your reply to:

Draft