K2 Appit - Articles
Community articles and FAQ's for K2 Appit.
cancel
Showing results for 
Search instead for 
Did you mean: 

Showing Images in a List View

We will focus in this post on how to display images in a column on a list view. In my example below, I will be leveraging a SmartObject from an appified SharePoint Picture Library as the source for my images, but any SmartObject with a method call that will provide an array of hyperlinks to the images that you would like to use will also work.

 

Setup

 

I create a SharePoint Picture Library entitled "Image Directory" and add a few images to the library, then appify the Picture Library.

 

image_directory.png

 

The SmartObject created for this library, by default, has a Get Documents method that will provide a "Link to Item" parameter that I can leverage on a list view to populate the list with thumbnails of the images.

 

I can now create a new View (either within 'Image Directory,' or from the artifacts page of any other appified list or library), configured as a List View, and tied to the SmartObject of Image Directory.

 

list_view_designer_1.png

 

On the Layout tab, I click to create a table with two columns. For the first column, I add the "Name" field from the browser on the right. In the second column, I add a Data Label control. The Data Label (renamed Thumbnail) is what I will use to display the images.

 

list_view_designer_2.png

 

For the Data Label control, an expression can now be written to dynamically populate the control with an HTML <img> tag referencing the link to the item. See the image below for the proper configuration. Note that I also am controlling the width of the image to create a thumbnail version of the image.

 

Written expression: <img src="[Link to Item]" width="150">

 

list_view_designer_3.png

 

Make sure to check the "Literal" box in the properties for the Data Label. This will allow the control to render the HTML, instead of just displaying the text of the <img> tag.

 

Result

 

list_view.png

 

Optional

 

After building a SmartForm off of this View, I added a "When a View raises and event" rule that fires when a list item is double-clicked that will navigate to a URL, adding in the "Link to Item" as the URL so double-clicking will open a full-size copy of the image. An image of the configuration and the behavior can be seen below.

 

navigate_rule.png

 

double_click.png

No ratings
Comments
K2_Beginner

You rock!!

riva

For those using K2 SmartBox to store images (instead of SharePoint), there's another workaround here: https://how2k2.wordpress.com/2017/02/22/displaying-full-res-images-in-a-list-view/ 

joew

Great example.  You might want to consider using "Get Documents Metadata" instead of "Get Documents".  Get Documents actually down loads the file contents to the K2 Server, when all you need is the "Link to Item" field.  Thanks for the help.  

Contributors