public TablesPropertyValueConverter(IUmbracoContextAccessor umbracoContextAccessor, IMacroRenderer macroRenderer, HtmlLocalLinkParser linkParser, HtmlUrlParser urlParser, HtmlImageSourceParser imageSourceParser) { _rteRenderingValueConverter = new RteMacroRenderingValueConverter(umbracoContextAccessor, macroRenderer, linkParser, urlParser, imageSourceParser); }
/// <summary> /// Convert img to img srcset, extracts width and height from querystrings /// </summary> /// <param name="htmlHelper"></param> /// <param name="publishedContent"></param> /// <param name="propertyAlias">Alias of the TinyMce property</param> /// <param name="generateLqip">Set to true if you want LQIP markup to be generated</param> /// <param name="removeStyleAttribute">If you don't want the inline sytle attribute added by TinyMce to render</param> /// <param name="roundWidthHeight">Round width & height values as sometimes TinyMce adds decimal points</param> /// <returns>HTML Markup</returns> public static IHtmlString ConvertImgToSrcSet(this HtmlHelper htmlHelper, IPublishedContent publishedContent, string propertyAlias, bool generateLqip = true, bool removeStyleAttribute = false, bool roundWidthHeight = true) { var dataValue = publishedContent.GetProperty(propertyAlias).DataValue.ToString(); var source = ConvertImgToSrcSetInternal(htmlHelper, dataValue, generateLqip, removeStyleAttribute, true, roundWidthHeight); // We have the raw value so we need to run it through the value converter to ensure that links and macros are rendered var rteConverter = new RteMacroRenderingValueConverter(); var sourceValue = rteConverter.ConvertDataToSource(null, source, false); var objectValue = rteConverter.ConvertSourceToObject(null, sourceValue, false); return(objectValue as IHtmlString); }