Media Library on a Structured Page - Kentico 11

Duncan Koza asked on November 27, 2019 18:38

Hello,

All my pages are structured pages running from one template. My page types control what elements on the template get shown.

I want my end user to be able to select a folder in the media library via their structured page. What field type/control should I use?

Then on my template, which webpart should I pick to show the Media Library?

Finally, what are the field names of the title and description fields for the images in the Media Library? Because I'll want to call the values of those fields. I am using my own bootstrap image gallery to style it.

Recent Answers


David te Kloese answered on November 28, 2019 14:09 (last edited on November 28, 2019 14:10)

I've not seen an out of the box solution for that.

The database only contains data about files and not the folders. So you probably end up with a control that checks on file system what folders are present. You might be able to use some of the controls used by the Kentico modules.

You could "cheat" it bit just using the default media select control and ask to select any item in the Folder. And handle it in code.

-

For listing you would need to get all media items from the folder. You could query something like:

MediaFileInfoProvider.GetMediaFiles()
.WhereEquals("FileLibraryID","123456")
.WhereStartsWith("FilePath", thePathSelectedByTheEditor;

This would return the files that are registered in the DB. (note this does also include sub-folder items)

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.