<p>You should be able to get it with the <code>getURL()</code> method?</p>

<p>Something like this should work (NB! have not tested the code myself):</p>

<pre><code>$image = $entry-&gt;image-&gt;first();
if ($image) {
    $url = $image-&gt;getUrl();
}
</code></pre>

CC BY-SA 4.0
2019-02-19T12:27:37.063Z
He's asking about the path, not the URL
Fuglsetrampen
CC BY-SA 3.0
2017-07-29T16:40:10.137Z
2017-07-29T16:40:10.137Z
KSP
<p>I've written a simple plugin that attaches to the onSaveEntry event. I'd like to access the image, extract the colours from the image using <a href="https://github.com/brianmcdo/ImagePalette" rel="nofollow noreferrer">https://github.com/brianmcdo/ImagePalette</a> and then save these colours to a field. I've managed to access the entry, but can't seem to find how to get the path and filename of the image?</p>

<p>Any help would be greatly appreciated!</p>

<p>Thanks</p>

<plugin-development><assets>
How do I get the full path of an asset?
# How do I get the full path of an asset?

(Asked by: username_0 on 2017-07-28)

I've written a simple plugin that attaches to the onSaveEntry event. I'd like to access the image, extract the colours from the image using <https://github.com/brianmcdo/ImagePalette> and then save these colours to a field. I've managed to access the entry, but can't seem to find how to get the path and filename of the image?

Any help would be greatly appreciated!

Thanks

**Tags:** plugin-development, assets


---

## 1 answers

### Answer by username_1 on 2017-07-29. Score: 0

You should be able to get it with the getURL() method?
Something like this should work (NB! have not tested the code myself):
$image = $entry->image->first();
if ($image) {
    $url = $image->getUrl();
}

> **Comments:**
> **username_2**: He's asking about the path, not the URL  

---

