Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Kyber.Entities;
  6. using umbraco.cms.businesslogic.datatype;
  7. using System.Collections;
  8. using umbraco.cms.businesslogic.media;
  9.  
  10. namespace Kyber.CropUtilities
  11. {
  12.     public class CropUtilities
  13.     {
  14.         /// <summary>
  15.         /// Get the path to a cropped media item
  16.         /// </summary>
  17.         /// <param name="_sCropName"></param>
  18.         /// <param name="_mMedia"></param>
  19.         /// <returns>the path to the cropped image</returns>
  20.         public static String GetPathForCroppedMediaItem(String _sCropName, Media _mMedia)
  21.         {
  22.             String _sPath = String.Empty;
  23.             if (!String.IsNullOrEmpty(_sCropName))
  24.             {
  25.                 foreach (CropFormat _cropFormat in new CropFormats().AvailableCropFormats)
  26.                 {
  27.                     if (_cropFormat.CropName.Equals(_sCropName))
  28.                     {
  29.                         String _sImgPath = _mMedia.getProperty("umbracoFile").Value.ToString();                        
  30.                         String _sPathWithoutExtension = _sImgPath.Substring(0, _sImgPath.LastIndexOf("."));
  31.                         return _sPathWithoutExtension + "_" + _sCropName + ".jpg"; // The cropper only supports generation of jpgs.
  32.                     }
  33.                 }
  34.             }
  35.  
  36.             return "";
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement