<p>A simple method would be to <a href="https://twig.symfony.com/doc/2.x/filters/trim.html" rel="nofollow noreferrer">trim</a> the extension from the filename (see <a href="https://twigfiddle.com/ul81i9" rel="nofollow noreferrer">this fiddle</a>):</p>

<pre><code>{{ assetsField.filename|trim('.' ~ assetsField.extension, 'right') }}
</code></pre>

CC BY-SA 4.0
2019-07-21T21:55:16.370Z
2019-07-21T21:55:16.370Z
Cue
<p>How do I get an asset's filename without the extension? So if my filename is <code>my_cool_photo.jpg</code> I want to return <code>my_cool_photo</code>. Using <code>{{ entry.assetsField.one.filename }}</code> returns the name of the file with the extension included.</p>

<templating><assets>
Get an Asset's Filename Without the Extension
# Get an Asset's Filename Without the Extension

(Asked by: username_0 on 2019-07-19)

How do I get an asset's filename without the extension? So if my filename is `my_cool_photo.jpg` I want to return `my_cool_photo`. Using `{{ entry.assetsField.one.filename }}` returns the name of the file with the extension included.

**Tags:** templating, assets

---

## 1 answers

### Answer by username_1 on 2019-07-21. Score: 3 | Accepted answer

A simple method would be to trim the extension from the filename (see this fiddle):
{{ assetsField.filename|trim('.' ~ assetsField.extension, 'right') }}


---

