> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/template-architecture/images-in-s-docs/dynamic-image-solutions/related-list-examples-that-pull-images-stored-in-files-attachments.md).

# How to: Images & Related Lists

This page will guide the user through how to pull images from Salesforce Object Records that are stored in the Files or Attachments related lists.

## Images from Files Related List

```
<!--{{!
<lineitemsSOQL><class>table999</class>
<soql>select ContentDocument.latestpublishedversionid, ContentDocument.LatestPublishedVersion.pathonclient from contentdocumentlink where LinkedEntityId='{!ObjectID15}' AND (ContentDocument.LatestPublishedVersion.pathonclient LIKE'%.jpg%')
</soql>
<column prefix="<img src='/sfc/servlet.shepherd/version/download/" postfix="' width='150px' />">ContentDocument.latestpublishedversionid</column>
</lineitemsSOQL>
}}-->
```

Insert the above code snippet directly into the Template Editor's Source.

{% hint style="info" %}
The above code snippet is searching for image's stored on the Object Record of type JPG. To generate properly, change **.jpg** in **LIKE'%.jpg%'** to the image format that was uploaded.
{% endhint %}

<figure><img src="https://1548664070-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWKNnJmhJBQwhdk5WBFsi%2Fuploads%2F0xJVFWQ1hzVexOLv4liR%2Fimage.png?alt=media&amp;token=f0c459f3-3fbb-4ae2-a09e-c60ef365c489" alt=""><figcaption></figcaption></figure>

## Images from Attachments

{% hint style="info" %}
Images stored in attachments is considered legacy in comparison to storing images as Files/ContentDocuments. The Salesforce Lightning Experience will **automatically convert uploads to Notes & Attachments to Salesforce Files**. In order to upload Attachments, use **Salesforce Classic**.
{% endhint %}

In Salesforce Classic, Navigate to the Object Record, Select Attach File, upload the selected image. The following code block will now operate as expected.

<figure><img src="https://1548664070-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWKNnJmhJBQwhdk5WBFsi%2Fuploads%2FQZEkkAePg8fYXbBSWHYE%2Fimage.png?alt=media&amp;token=1bf3404f-ee2e-44d8-bf6e-08b5849f89cf" alt=""><figcaption></figcaption></figure>

```
<!--{{!
<lineitemsSOQL>
<class>table999</class>
<soql>Select id, name from attachment where parentId='{!ObjectID15}' AND (name LIKE'%.jpg%')</soql>
<column prefix="<img src='/servlet/servlet.FileDownload?file=" postfix="' width='150px' />">id</column>
</lineitemsSOQL>}}-->
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.sdocs.com/sdocs/template-architecture/images-in-s-docs/dynamic-image-solutions/related-list-examples-that-pull-images-stored-in-files-attachments.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
