Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

blobfactory

Vote:
 

I'd like to fetch all images belonging to a page from code. Is that feasible in Episerver 7.5 via the blobfactory?

#82389
Mar 11, 2014 14:04
Vote:
 

What about following code?

var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
var helper = ServiceLocator.Current.GetInstance<ContentAssetHelper>();
var folder = helper.GetAssetFolder(CurrentPage.ContentLink);
var images = contentRepository.GetChildren<MediaData>(folder.ContentLink);

    

#82410
Mar 11, 2014 20:27
Vote:
 

That probably works. I ended up with the following lines of code:

 

 

var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();

var contentAssetFolder = contentRepository.Get<ContentAssetFolder>(page.ContentAssetsID);

images = contentRepository.GetChildren<

ImageFile>(contentAssetFolder.ContentLink);

#82519
Mar 14, 2014 8:56
Vote:
 

Pardon for the unformatted code. How do I go about pasting the code with its original formatting?

 

//Daniel

#82520
Mar 14, 2014 8:57
Vote:
 

You shoud insert code block (1st icon in toolbar).

#82522
Mar 14, 2014 9:13
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.