<p>What you want is <a href="http://buildwithcraft.com/docs/templating/craft.assets" rel="nofollow">craft.assets</a></p>

<blockquote>
  <p>You can access your site’s assets from your templates via craft.assets. It returns an ElementCriteriaModel object.</p>
</blockquote>

<p>Use <code>sourceId</code> for the parameter.</p>

<p>To find the sourceId, look at the <code>craft_assetsources</code> table in the database. There doesn't seem to be any way to query for <a href="http://buildwithcraft.com/docs/templating/assetsourcemodel" rel="nofollow">AssetSourceModel</a>.</p>

CC BY-SA 3.0
2014-09-21T12:05:04.667Z
Yes I saw this. It's pretty cryptic though, how do I find the sourceId?
hamishtaplin
CC BY-SA 3.0
2014-09-22T08:20:44.807Z
Thanks, this works. Not a very intuitive solution though, I would hope there is a better way than having to look up id's in the database!
hamishtaplin
CC BY-SA 3.0
2014-09-19T16:40:18.153Z
2014-09-21T17:21:11.600Z
2014-09-21T17:21:11.600Z
Marion Newlevant
<p>You can fetch assets related to a certain source by using the <a href="https://craftcms.com/docs/templating/craft.assets#source" rel="nofollow noreferrer">craft.assets.source</a> method and passing in the source handle. </p>

<p>Assuming your handle is 'my_images', the following will do the job:</p>

<pre><code>craft.assets.source('my_images')
</code></pre>

<p>You avoid having to lookup db IDs that way.</p>

CC BY-SA 3.0
2017-12-05T09:07:31.230Z
Note: If you want to pull _all_ Assets, be sure to set the `limit` parameter to `null`, i.e. `{% set assets = craft.assets.source('my_images').limit(null) %}`, otherwise your query will be limited to 100 Assets.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2017-12-05T03:44:38.820Z
2017-12-05T03:44:38.820Z
zumek
<p>I have a bunch of images that aren't related to any entries but are in an asset source. Let's call this 'My Images'.</p>

<p>How do I just grab those assets? I can't find anything in the docs that suggests this is possible—it seems such an obvious use-case though I'm sure I am missing something.</p>

<assets>
Get assets from an asset source
# Get assets from an asset source

(Asked by: username_0 on 2014-09-19)

I have a bunch of images that aren't related to any entries but are in an asset source. Let's call this 'My Images'.

How do I just grab those assets? I can't find anything in the docs that suggests this is possible—it seems such an obvious use-case though I'm sure I am missing something.

**Tags:** assets

---

## 2 answers

### Answer by username_1 on 2014-09-19. Score: 4

What you want is [craft.assets](http://buildwithcraft.com/docs/templating/craft.assets)

> You can access your site’s assets from your templates via craft.assets. It returns an ElementCriteriaModel object.

Use `sourceId` for the parameter.

To find the sourceId, look at the `craft_assetsources` table in the database. There doesn't seem to be any way to query for [AssetSourceModel](http://buildwithcraft.com/docs/templating/assetsourcemodel).

> **Comments:**
> **username_0**: Yes I saw this. It's pretty cryptic though, how do I find the sourceId?  
> **username_0**: Thanks, this works. Not a very intuitive solution though, I would hope there is a better way than having to look up id's in the database!  

---

### Answer by username_2 on 2017-12-05. Score: 3

You can fetch assets related to a certain source by using the craft.assets.source method and passing in the source handle. 
Assuming your handle is 'my_images', the following will do the job:
craft.assets.source('my_images')

You avoid having to lookup db IDs that way.

> **Comments:**
> **username_3**: Note: If you want to pull _all_ Assets, be sure to set the `limit` parameter to `null`, i.e. `{% set assets = craft.assets.source('my_images').limit(null) %}`, otherwise your query will be limited to 100 Assets.  

---

