This topic explains how to link data grids to external image files which reside either in LabKey Server, or somewhere else on the web.

This feature can be used with any LabKey data table, but is especially important in the context of study datasets, because study datasets do not support either the File or Attachment field types. This means you cannot directly include a file or image as part of a row of data in a dataset. By linking to an external file/image, you can overcome this inherent limitation of study datasets.

For assay designs, see the following topic: Linking Assays with Images and Other Files.

Scenario

Suppose you have a dataset where each of row of data refers to some image or file. For example, you have a dataset called Biopsies, where you want each row of data to link to an image depicting a tissue section. Images will open in a new tab or download, depending on your browser settings.

Below is an example Biopsies table:

Biopsies

ParticipantIdDateTissueTypeTissueSlide
PT-10110/10/2010Liverslide1.jpg
PT-10210/10/2010Liverslide2.jpg
PT-10310/10/2010Liverslide3.jpg

How do you make this dataset link to the slide images, such that clicking on slide1.jpg shows the actual image file?

Solution

To achieve this linking behavior, follow these steps:

  • Upload the target images to the File Repository.
  • Import a dataset where one column contains the image names.
  • Build a URL that links from the image names to the image files.
  • Use this URL in the dataset.
Detailed explanations are provided below:

Upload Images to the File Repository

  • Navigate to your study folder.
  • Go to Admin > Go To Module > File Content.
  • Drag-and-drop your files into the File Repository. You can upload the images directly into the root directory, or you can upload the images inside a subfolder. For example, the screenshot below, shows a folder called images, which contains all of the slide JPEGs.
  • Acquire the URL to your image folder: In the File Repository, open the folder where your images reside, and scroll down to the WebDav URL.
  • Open Notepad, or any text editor, and paste in the URL, for example:
https://myserver.labkey.com/_webdav/myproject/%40files/images/

Import Dataset

You dataset should include a column which holds the file names of your target images. See "Biopsies" above for an example.

For details on importing a study dataset, see Import Datasets.

Build the URL

To build the URL to the images, do the following:

  • In your dataset, determine which column holds the image names. In our example the column is "TissueSlide".
  • In a text editor, type out this column name as a "substitution token", by placing it in curly brackets preceded by a dollar sign, as follows:
${TissueSlide}
  • Append this substitution token to the end of the WebDav URL in your text editor, for example:
https://myserver.labkey.com/_webdav/myproject/%40files/images/${TissueSlide}
  • You now have a URL that can link to any of the images in the File Repository.

Use the URL

null
  • Go the Dataset grid view and click Manage.
  • Click Edit Definition.
  • Click the Fields section.
  • Use to expand the field which holds the image names, in this example, "TissueSlide".
  • Into the URL field, paste the full URL you just created, including the substitution token.
  • Click Save.
  • Click View Data.
  • Notice that the filenames in the TissueSlide field are now links. Click a link to see the corresponding image file. It will open in a new tab or download, depending on your browser.

If you prefer that the link results in a file download, add the following to the end of the URL in the dataset definition.

?contentDisposition=attachment

Resulting in this total URL on the Display tab for the TissueSlide field.

https://myserver.labkey.com/_webdav/myproject/%40files/images/${TissueSlide}?contentDisposition=attachment

Related Topics

Was this content helpful?

Log in or register an account to provide feedback


previousnext
 
expand allcollapse all