# How to: Images & 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="/files/XRSk3KseNP9pmGkffg9A" 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**.  &#x20;
{% 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="/files/L3q6OjDFPpfjiHHK0Uo1" 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
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>
```

The question should be specific, self-contained, and written in natural language.
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.
