How can I display images,Description, other File Properties from Media Library in Static HTML or Cus

Trey Aughenbaugh asked on March 24, 2017 13:49

I searched and found this comment about it being impossible, unless you create a Custom Webpart. link text

At first I was using a Repeater with Effects to display my images from a Media Library in a row. 5 images happens to not fit right, so I need to do a row of 3, then 2. I pull in the Image, File Description and Title to populate the web page. Its works perfect as a single row of 5. Being really new to Kentico, I am not sure how to do this. Could I still use the repeater and create a Header and footer or use some of the other transformation options to do 3 and 2? Is there another existing Web part that will let me do this? In this case, there will always be 5 images.

Thank you.

Since in this case there will always be 5 images, don't need to use a repeater, I'm just not sure how to access the media library properties from static html.

Correct Answer

Brenden Kehren answered on March 24, 2017 18:11

Yes, this is the perfect setup for a page type. You can also do what Peter M mentioned as well with a repeater but I'll explain a bit more the concept I'm talking about.

Page type: Slider (or whatever you want to name it) Image Text

Page content setup and template ** notice the folder under the home page. This holds the new page type you just created. They will never be navigated to individually, they are simply blocks of content, in my case a slide in my slider. Image Text

In your repeater define the properties and setup the transformation:

Image Text

Page types don't have to be physical pages people navigate to. Make them reusable content blocks. I'd suggest installing the Dancing Goat site as a guide and something to give you inspiration from and follow for examples.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on March 24, 2017 15:10

Can Media Gallery be useful in your case?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 24, 2017 15:16

You could do what I suggested on the other post. Another option is to create a widget out of the repeater webpart. A widget is a scaled down version of a webpart. Essentially you make the widget preconfigured with the objects, transformations, etc and then simply let the user/content editor select where they want to get, say the images from. Everything else is already preconfigured for them. Check out widgets and see if they might work.

0 votesVote for this answer Mark as a Correct answer

Trey Aughenbaugh answered on March 24, 2017 15:22

Hi Peter, I'm not sure how much control I have with the Media Gallery. For example, in the Repeater with Effect, I had this, along with a Content before and Content After. Again, this worked out nicely, until I had to change the number of items on the first row. I will look over the Media Library and see what I can figure out. Being New to Kentico, its taking a minute to figure out all the best methods to use. Thanks for taking the time to reply!

<div class="<%# IfCompare(GetNotEmpty("FileName"),"service-1","col-sm-2", "col-sm-2 col-md-offset-1") %>">
    <div class="image-box style-2 mb-20">
        <div class="overlay-container overlay-visible">
            <img src="<%# CMS.MediaLibrary.MediaFileInfoProvider.GetMediaFileUrl(new Guid(Eval("FileGUID").ToString()), CurrentSite.SiteName) %>" alt=""/>
            <a href="<%# CMS.MediaLibrary.MediaFileInfoProvider.GetMediaFileUrl(new Guid(Eval("FileGUID").ToString()), CurrentSite.SiteName) %>" class="overlay-link popup-img"><i class="fa fa-plus"></i></a>
            <div class="overlay-bottom hidden-xs">
                <div class="text">
                    <p class="lead margin-clear text-left"><%# GetNotEmpty("FileTitle;FileName") %></p>
                </div>
            </div>
        </div>
        <div class="body padding-horizontal-clear">
            <p><%# GetNotEmpty("FileDescription") %></p>
        </div>
    </div>
</div>
0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on March 24, 2017 16:43

You were asking for media file properties. They already in the default transformation. This is essentially the same as repeater, You can copy/modify transformation Community.Transformations.MediaLibrary. For number of items you can use bootstrap grid system.

0 votesVote for this answer Mark as a Correct answer

Trey Aughenbaugh answered on March 24, 2017 16:44

Thanks Brenden, What I'm trying to make is basically a Home page section that will not be used anywhere else on the site. So if they need to change the image or data associated with the image, they can just edit Description in the Media Library. Based on the code above I posted, this works.

Although, I'm going to see an issue down the road with this approach. When you click on the image, it should link to a Specific page in Kentico instead of showing the image. Which I won't be able to pull from the File Properties. Okay, well, I now need to change this. In the end, its going to end up being a Visual Menu, with images from a media Gallery where the number of files wont be changing, just possible a new image and maybe some updated text. I was hoping to pull from the image properties, but now that I need a URL as well. I have to change my design a little.

Well, thanks to both of you, I may need to see about using a CSS menu of some sort for this then. Again, all new to me and I appreciate any input you have.

I'm a C# .Net web developer who is familiar with Master Templates, but due to picking up where someone left off, we are using Kentico Portal Engine instead of a more Visual Studio approach, which is killing me. I have a bootstrap template design mock-up and moving into Kentico, I'm running into Gotchas like above. I think I can do things one way, and I run into these little scenarios where I have to change my way of thinking. Devnet has been a great amount of help!

Have a great day.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on March 24, 2017 16:57

Easier way to do this then is to create a new Page Type with the fields you need. For instance:

  • Name
  • File URL (URL Selector control, which can then revert back to the media library)
  • File Description
  • LinkUrl (URL Selector control)
  • LinkTarget (normal or new window)

Then, under your home page, place a new page type (you just created) and fill out the fields. Next place a repeater on your home page template and specify the page type you just created and a transformation. The transformation will utilize the fields you just filled out on the Form tab and will dynamically display the items with their images, links etc. When you create a new transformation, click the Generate default transformation button so it places the available fields in place for you. Then add your markup and insert those values in place to dynamically update the values.

Also check out the Transformation Methods documentation for additional methods available in transformations.

0 votesVote for this answer Mark as a Correct answer

Trey Aughenbaugh answered on March 24, 2017 17:09

Awesome response Brenden. Much appreciated.

Just wondering if it has to be a page type, or maybe I'm not understanding all the uses of a page type. This Image Menu will be under a rotating Image banner and before some other content on the home page.

  • [Header/css menu]
  • [Banner Image - rotating]
  • [was...Media Library based Menu selection] - Can a page type be put in here?
  • [More cool how great we are content]
  • [Footer]

I apologize for limited information up front, the question and path has changed with each response, but maybe providing as much detail up front would have given you a better representation of what I need to do. Being in IT, I apologize for being on the other side of not giving enough details up front.

0 votesVote for this answer Mark as a Correct answer

Trey Aughenbaugh answered on March 24, 2017 17:11

Peter, your answer seems like a good approach for some other pages I have to create and possibly this one as well. Can you elaborate on how that is accomplished or provide a link to an example?

Thank you.

0 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on March 24, 2017 18:02

If you clearly define what you are trying to accomplish - we can try to help you with an answer. You should start by looking at sample site examples. They usually have to answers to common questions/problems. Install Kentico on your local machine with all sample sites. There are lots of typical scenarios and ready-to-use solutions.

0 votesVote for this answer Mark as a Correct answer

Trey Aughenbaugh answered on March 24, 2017 19:17

Thank you both so much. This is great info!

0 votesVote for this answer Mark as a Correct answer

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