Getting last three images with XSLListViewWebPart
-
08-12-2019 - |
Question
I am trying to get the latest three images added to a picture library and put them on home page with XSLListViewWebPart but can't manage it to work. Here is the sample output I am trying to get:
<img src="s-1.jpg" alt="" /><img src="s-2.jpg" alt="" /><img src="s-3.jpg" alt="" />
Is it ok to use XSLTListViewWebPart for this or should I choose any other way?
Thanks.
La solution
I have found one nice example that uses Content Query WebPart (CQWP):
Customize Content Query Webpart in Sharepoint 2010 and Deploy it using Visual Studio 2010
Similar question: Rendering images in a content query webpart
And a much simpler solution: How to Use SharePoint 2010 Content Query Web Part (CQWP)
I would go in this direction if custom layout is needed. XSLListViewWebPart is more list oriented.
Autres conseils
Content Query WebPart (CQWP) maybe a better choice for you. Try this:
- Insert a CQWP into your page, then
- Config the CQWP, select the Picture Library as the "Query" source, then
- Select "Created" as the "Group and Sort"'s sort column and check the "Descending" option, then
- Set "Limit the number of items to display" to 3, then
- In the "Style" section, select "Image only, clickable", then
- Change the CQWP's Title in the "Apparence" section, then
- Save your configuration.
by default, the CQWP will layout your images in vertical. if you want a horizontal layout, you can add this css style into your page or into a Content Editor Web Part:
<style>
.dfwp-item {
float:left;
}
</style>