nfourtythree/SecureAssetDownload

How do I get asset id?

subratom opened this issue · 2 comments

I am generating download URLs for the content. Assets are embedded inside of content, how do I get asset id from the file name?

Although the functionality at the moment doesn't cater for being passed a filename (although that is a good idea), you can get the ID of an asset in template tags by doing the following

{% set assetId = craft.assets({ filename: "my-filename.txt" }).first().id %}

Thank you that worked!