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...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
"'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...