Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using Kyber.Entities;
- using umbraco.cms.businesslogic.datatype;
- using System.Collections;
- using umbraco.cms.businesslogic.media;
- namespace Kyber.CropUtilities
- {
- public class CropUtilities
- {
- /// <summary>
- /// Get the path to a cropped media item
- /// </summary>
- /// <param name="_sCropName"></param>
- /// <param name="_mMedia"></param>
- /// <returns>the path to the cropped image</returns>
- public static String GetPathForCroppedMediaItem(String _sCropName, Media _mMedia)
- {
- String _sPath = String.Empty;
- if (!String.IsNullOrEmpty(_sCropName))
- {
- foreach (CropFormat _cropFormat in new CropFormats().AvailableCropFormats)
- {
- if (_cropFormat.CropName.Equals(_sCropName))
- {
- String _sImgPath = _mMedia.getProperty("umbracoFile").Value.ToString();
- String _sPathWithoutExtension = _sImgPath.Substring(0, _sImgPath.LastIndexOf("."));
- return _sPathWithoutExtension + "_" + _sCropName + ".jpg"; // The cropper only supports generation of jpgs.
- }
- }
- }
- return "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement