Is it possible to reference an image that's embedded in a grid?
Hi
I have a news article. Ive used grid to build up the article template.
On row two I have an image, there will always be an image there.
Is it possible to reference an image that's embedded in a grid from a macro? Any helpers or points would be fantastic.
Hey
So am sure there are 100 ways to do this better
var myGrid = @item.GetPropertyValue("articleGrid").ToString();
var myIndex = myGrid.ToString().IndexOf("udi");
myIndex = myIndex + 6;
var myImagePartOne = myGrid.Substring(@myIndex,500);
var myEndIndex = myImagePartOne.ToString().IndexOf(",");
var myImageUDI = myImagePartOne.Substring(0,myEndIndex).Replace('"', ' ').Trim();
var udi = Udi.Parse(myImageUDI);
var media = Umbraco.TypedMedia(udi);
var imageToShow = Url.GetCropUrl(media, 120, 120,quality:90, furtherOptions:"&format=jpg");
Is it possible to reference an image that's embedded in a grid?
Hi I have a news article. Ive used grid to build up the article template. On row two I have an image, there will always be an image there. Is it possible to reference an image that's embedded in a grid from a macro? Any helpers or points would be fantastic.
yes and no :)
Do you want to reference it in a controller, razor, clientside etc?
It's "just" json, so you can parse it , and check if the second row contains an image.
If you are on the server (a controller or razor) you are able to use the Skybrud.Umbraco.GridData package - read more here: https://skrift.io/articles/archive/strongly-typed-models-in-the-umbraco-grid/
Inside the grid partial, you can also check if the row number is 2, and if the control being rendered is using the editor named "image"
Hey So am sure there are 100 ways to do this better
But I got my image and it uses the image cropper.
is working on a reply...