<p>Add a lightswitch field to your assets and query for assets with the lightswitch enabled first. Use the <code>ids()</code> method to get just the assets' IDs and merge them with the rest of your assets' IDs to have them all in your desired sort order.</p>

<p>You can now query for the assets models by passing that IDs array to
the <code>id</code> parameter and adding <code>fixedOrder(true)</code>.</p>

<pre><code>{% set stickyImagesIds = craft.assets({
    folderId: 18,
    order: filename
    sticky: true
}).ids() %}

{% set regularImagesIds = craft.assets({
    folderId: 18,
    order: filename
}).ids() %}

{% set allImagesIds = stickyImagesIds|merge(
    regularImagesIds|without(stickyImagesIds)
) %}

{% set allImages = craft.assets.id(allImagesIds).fixedOrder(true).limit(240) %}
</code></pre>

CC BY-SA 3.0
2015-09-02T14:19:44.937Z
2015-09-02T14:19:44.937Z
carlcs
<p>Based on adding a lightswicht ("sticky") as suggested by <a href="https://craftcms.stackexchange.com/users/125/carlcs">@carlcs</a> I think you should be able to solve this by just using two order fields.</p>

<pre><code>{% set images = craft.assets.folderId(18).order('sticky desc, filename asc').limit(240); %}
</code></pre>

<p>You should be able to save some twig code, maybe even requests. Haven't tested this though. </p>

CC BY-SA 3.0
2015-09-02T15:18:53.947Z
carlcs and pascal's suggestion combined did the trick meanwhile saving some twig code. Both brilliant and simple ;-)
Robbie Post
CC BY-SA 3.0
2015-09-02T14:36:25.993Z
2015-09-02T14:36:25.993Z
2017-04-13T12:50:59.930Z
Pascal Mollet
<p>I have a list of images that are loaded directly from the content of a specific asset folder.</p>

<pre><code>{% for image in craft.assets.find({ folderId: 18, limit: 240, order: filename }) %}
</code></pre>

<p>What I want to achieve is that one (or more) images from that assets folder are listed first (second etc.) before the actual ordering by filename starts place. 
Much in the same way as sticky entries (EE).</p>

<assets><image>
Is there a way to create a "sticky" asset
# Is there a way to create a "sticky" asset

(Asked by: username_0 on 2015-09-02)

I have a list of images that are loaded directly from the content of a specific asset folder.
{% for image in craft.assets.find({ folderId: 18, limit: 240, order: filename }) %}

What I want to achieve is that one (or more) images from that assets folder are listed first (second etc.) before the actual ordering by filename starts place. 
Much in the same way as sticky entries (EE).

**Tags:** assets, image


---

## 2 answers

### Answer by username_1 on 2015-09-02. Score: 5 | Accepted answer

Add a lightswitch field to your assets and query for assets with the lightswitch enabled first. Use the ids() method to get just the assets' IDs and merge them with the rest of your assets' IDs to have them all in your desired sort order.
You can now query for the assets models by passing that IDs array to
the id parameter and adding fixedOrder(true).
{% set stickyImagesIds = craft.assets({
    folderId: 18,
    order: filename
    sticky: true
}).ids() %}

{% set regularImagesIds = craft.assets({
    folderId: 18,
    order: filename
}).ids() %}

{% set allImagesIds = stickyImagesIds|merge(
    regularImagesIds|without(stickyImagesIds)
) %}

{% set allImages = craft.assets.id(allImagesIds).fixedOrder(true).limit(240) %}


---

### Answer by username_2 on 2015-09-02. Score: 8

Based on adding a lightswicht ("sticky") as suggested by @username_1 I think you should be able to solve this by just using two order fields.
{% set images = craft.assets.folderId(18).order('sticky desc, filename asc').limit(240); %}

You should be able to save some twig code, maybe even requests. Haven't tested this though.

> **Comments:**
> **username_0**: username_1 and pascal's suggestion combined did the trick meanwhile saving some twig code. Both brilliant and simple ;-)  

---

