Copied to clipboard

Flag this post as spam?

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


  • Jacob Bach Pedersen 19 posts 73 karma points
    Sep 25, 2014 @ 16:08
    Jacob Bach Pedersen
    0

    Resize image

    Is it possible to resize an image using GetCropUrl() only setting ie. max width?

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 25, 2014 @ 16:18
    Jeavon Leopold
    0

    Yes it is, could you post your current code where you wish to do this so I can give you the correct snippet?

  • Jacob Bach Pedersen 19 posts 73 karma points
    Sep 25, 2014 @ 16:21
    Jacob Bach Pedersen
    0

    <img src="@media.GetCropUrl("bigImage")" alt="" />

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 25, 2014 @ 16:22
    Jeavon Leopold
    0

    Can you show me how you set @media?

  • Jacob Bach Pedersen 19 posts 73 karma points
    Sep 25, 2014 @ 16:22
    Jacob Bach Pedersen
    0

    var media = Umbraco.Media(page.GetValue<int>("image"));

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 25, 2014 @ 16:36
    Jeavon Leopold
    0

    Ok then, this should do it:

    At the top add:

    @using Umbraco.Web.Models
    

    Then

    @{
        var media = Umbraco.TypedMedia(page.GetValue<int>("image"));    
    }
    <img src="@media.GetCropUrl(propertyAlias:"bigImage", imageCropMode:ImageCropMode.Pad, width:300)" alt="" />
    
  • Jacob Bach Pedersen 19 posts 73 karma points
    Sep 25, 2014 @ 16:47
    Jacob Bach Pedersen
    0

    Thanks

  • 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