Accessing Images and Other Files

When you want to access a single asset (an image file, document file, or anything else that you've uploaded through the Files page), you simply use its filename:

<img src="/filename.jpg">

All files appear at the root of the site, unless you've explicitly put them in a folder.

You can use a taxonomy to identify groups of files. For example, suppose you have a taxonomy called "animals" and it includes the term "cat". This code shows all the photos tagged with the taxonomy term "cat":

<w:assets:each taxonomy="animals:cat">
  <img src="<w:path />">

If you want to associate files with a particular database item, use one of the related assets field types and access the files from within the context of the database item. For details on how to do this, see Working with Related Assets.

For details on accessing automatically generated image renditions, such as thumbnails, see Creating and Accessing Image Renditions.

Sometimes it is useful to use use a tagging technique instead to create the association. If you're within the context of a particular database item, and you want all the images with the same tag as the item, then you'd use:

  <w:assets tag="var[kb:item:tag]">

This technique is helpful when you want to associate a database item with a group of photos that are already tagged: just assign them all the same tag, and then use the code above to find the items that match the current item when you're displaying information about the item. One limitation: it uses the first tag it finds on the item, so it is only effective when the database item has only a single tag. The images, however, can have any number of tags. (In general, it is better to use the Multiple Shared Files field in the database item, as described in the article referenced above.)