Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I am creating a method that returns html for a picture element, but gets the below error.
My code is:
public static string PictureHtml(string[] srcsets, IPublishedContent image, string classAttr) { string output = ""; int i = 1; foreach (var srcset in srcsets) { string[] srcsetAttributes = srcset.Split('|'); if(i != srcsets.Count()) { output += "<srcset src=\"" + image.GetCropUrl(200, 200) + "\" />"; } else { output += "<img src=\"" + image.GetCropUrl(200, 200) + "\" alt=\"" + image.Name + "\" />"; } i++; } return "<picture class=\"" + classAttr + "\">" + output + "</picture>"; }
Code isn“t finished yet and therefore GetCropUrl parameters are hardcoded to 200.
Hi Martin,
I think you need to include the Umbraco.Web namespace as GetCropUrl is an extension method.
Umbraco.Web
GetCropUrl
Thanks
Nik
That works! Thanks!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
"'IPublishedContent' does not contain a definition for 'GetCropUrl'" in my method
Hi,
I am creating a method that returns html for a picture element, but gets the below error.
My code is:
Code isn“t finished yet and therefore GetCropUrl parameters are hardcoded to 200.
Hi Martin,
I think you need to include the
Umbraco.Web
namespace asGetCropUrl
is an extension method.Thanks
Nik
That works! Thanks!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.