Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 909 posts 2479 karma points
    Aug 07, 2017 @ 14:33
    Claushingebjerg
    0

    7.6.3 image cropper ... again

    As always i'm having trouble with the image cropper...

    I'm listsing sub pages of the current page and want a fixed crop from each page. Simple i guess...

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Gallerier>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
      Layout = "Master.cshtml";
      var selection = CurrentPage.Children().Where("Visible");
    }
    
    <div>
      @foreach(var item in selection){
          var mediaGet = item.GetPropertyValue<IPublishedContent>("teaserbillede");
          <img src="@mediaGet.GetCropUrl(width: 300, height: 200)" />
      }
    </div>
    

    Error: 'Umbraco.Web.PublishedContentModels.Image' does not contain a definition for 'GetCropUrl'

  • Claushingebjerg 909 posts 2479 karma points
    Aug 08, 2017 @ 08:32
    Claushingebjerg
    101

    Fixed it

     @foreach(var item in selection){
        var mediaGet = item.GetPropertyValue("teaserbillede");
          <div>
            @if (mediaGet != null) {
             int mediaID = @mediaGet.Id;
             var mediaItem = Umbraco.TypedMedia(@mediaID);
             <img src="@Url.GetCropUrl(mediaItem, width: 800, height: 300)" />
                } 
           </div>
      }
    
  • Simeon Ostberg 109 posts 354 karma points
    Nov 02, 2020 @ 12:03
    Simeon Ostberg
    1

    Hi Claus,

    Thanks a million times! With your code I could solve my cropper issue :)

    Best, Simeon

  • Claushingebjerg 909 posts 2479 karma points
    Nov 02, 2020 @ 12:06
    Claushingebjerg
    0

    You're welcome :)

Please Sign in or register to post replies

Write your reply to:

Draft