<p>You can use <code>relatedTo</code> for that:</p>

<pre><code>{% set entries = craft.entries.section('mySection').relatedTo(myAsset) %}
</code></pre>

<p>Or</p>

<pre><code>{% set entries = craft.entries({ section: 'mySection', relatedTo: myAsset }) %}
</code></pre>

<p>Check out <a href="http://buildwithcraft.com/docs/relations#the-relatedTo-param" rel="nofollow">the documentation on relationships</a>.</p>

CC BY-SA 3.0
2014-09-11T19:37:59.967Z
Thanks! Didn't realize that relatedTo would work without explicitly relating items.
jpea
CC BY-SA 3.0
2014-09-11T21:23:59.783Z
relatedTo is one of those magic ingredients that makes Craft look like something out of Harry Potter. :)
André Elvan
CC BY-SA 3.0
2014-09-11T19:08:50.673Z
2014-09-11T19:08:50.673Z
André Elvan
<p>Let's say that I have an Assets field on a single page where someone can add a bunch of images to a "gallery" on that page. Is there a way to perform a query and return the entries from a channel where these images are used as well?</p>

<p>Ideally, I'm trying to get the URL's to all of the listing entries where any of these images are also used, but without the admin explicitly relating them to those entries on the single page. There's no explicit relationship between them, other than the same images were used on both the single and channel entry. </p>

<assets>
Method for pulling entries that have a specific image linked?
# Method for pulling entries that have a specific image linked?

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

Let's say that I have an Assets field on a single page where someone can add a bunch of images to a "gallery" on that page. Is there a way to perform a query and return the entries from a channel where these images are used as well?

Ideally, I'm trying to get the URL's to all of the listing entries where any of these images are also used, but without the admin explicitly relating them to those entries on the single page. There's no explicit relationship between them, other than the same images were used on both the single and channel entry.

**Tags:** assets


---

## 1 answers

### Answer by username_1 on 2014-09-11. Score: 2 | Accepted answer

You can use relatedTo for that:
{% set entries = craft.entries.section('mySection').relatedTo(myAsset) %}

Or
{% set entries = craft.entries({ section: 'mySection', relatedTo: myAsset }) %}

Check out the documentation on relationships.

> **Comments:**
> **username_0**: Thanks! Didn't realize that relatedTo would work without explicitly relating items.  
> **username_1**: relatedTo is one of those magic ingredients that makes Craft look like something out of Harry Potter. :)  

---

