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 have i folder in media called my private photos for example im using media service to get the image as IMedia
_mediaService.GetMediaByPath("/media/adgasgd/someimage.jpg")
how can i find out witch folder this image belongs to ? I need to read custom properties from this folder
var myImage = _mediaService.GetMediaByPath("/media/adgasgd/someimage.jpg") var folder = _mediaService.GetById(myImage.ParentId);
Hi wilmar,
I have found easier to use the umbraco helper and work with IPublished content.
so if you are getting the image from the path then you can do that
var myImage = _mediaService.GetMediaByPath("/media/adgasgd/someimage.jpg"); var uHelper = Umbraco.Web.Composing.Current.UmbracoHelper; var iPublishedContentMyImage= uHelper.Media(myImage.Id); var privatePhotosFolder= iPublishedContentMyImage?.AncestorsOrSelf()?.Where(x => x.Name == "private photos")?.FirstOrDefault(); if(privatePhotosFolder != null){ ... }
With this one you can have multiple folders under your "Private Photos" folder
(btw its not tested)
Hope that helps
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How can i find out which folder belongs to an image im umbraco 8
Hi i have i folder in media called my private photos for example im using media service to get the image as IMedia
how can i find out witch folder this image belongs to ? I need to read custom properties from this folder
Hi wilmar,
I have found easier to use the umbraco helper and work with IPublished content.
so if you are getting the image from the path then you can do that
With this one you can have multiple folders under your "Private Photos" folder
(btw its not tested)
Hope that helps
is working on a reply...