Im new to EPiserver so im very much out of the loop on lots of things, but i thought maybe i could get some help here.
What i want to do is basically find if a page has a property that holds a reference to an image. Since there are seemingly many types of properties that can hold images(ContentAreas, ContentReferences, blocks, imageblocks within content areas etc.). Im not sure what the best course would be to look through all these properties within this page that possibly could hold a reference to an image.
I have this:
var writablePage = _contentRepository.Get<NewsPage>(pageLink).CreateWritableClone() as NewsPage;
Which lets me see and adjust the properties of this page as i want, which is good and all. But what would be the best way go about to find all the various types of properties that can hold an image reference?
Haven't tested this code. But something along these lines might work:
var links = ServiceLocator.Current.GetInstance<IContentSoftLinkRepository>()
// Not sure if this works on internal links...
var hasImage1 = links.Any(x => x.SoftLinkType == ReferenceType.ImageReference);
// This will only evaluate internal links
var hasImage2 = links.Any(x => _contentRepository.TryGet<ImageData>(x.ReferencedContentLink, out _));