Esempio n. 1
0
        public MvcHtmlString RenderImage(HtmlHelper helper, string imageUrl, Size targetSize = new Size(), string alt = null,
                                         string title = null, object attributes = null)
        {
            var cachingInfo = _mediaSettings.GetImageTagCachingInfo(imageUrl, targetSize, alt, title, attributes);

            return(helper.GetCached(cachingInfo, htmlHelper =>
            {
                using (new SiteFilterDisabler(_session))
                {
                    if (string.IsNullOrWhiteSpace(imageUrl))
                    {
                        return MvcHtmlString.Empty;
                    }

                    var imageInfo = GetImageInfo(imageUrl, targetSize);
                    if (imageInfo == null)
                    {
                        return MvcHtmlString.Empty;
                    }

                    return ReturnTag(imageInfo, alt, title, attributes);
                }
            }));
        }