Skip to main content

Questions tagged [assetfilemodel]

Filter by
Sorted by
Tagged with
15 votes
4 answers
5k views

How to get absolute path to asset file?

I have some csv files uploaded as assets and now I need to fopen() them from my plugin. I have an AssetFileModel but I have not been able to work out how to construct a full path to the file. I can ...
Jeremy Allen's user avatar
10 votes
1 answer
3k views

How do you delete assets from a frontend form?

I am creating a proof of concept for a client in Craft where the client's customers can manage projects from the frontend of a Craft install. I have a frontend form working correctly for creating a ...
Alan Miller's user avatar
8 votes
1 answer
694 views

Is it possible to hook into image transforms?

I have a somewhat unique thumbnail need for a certain site. I need to watermark images with custom text (per image, not globally across the site). Is there a way to hook into the Craft image transform ...
Mark Huot's user avatar
  • 125
5 votes
1 answer
864 views

How to set a field of an asset from within a plugin

I am using the following code to save an asset that has been downloaded to the storage/runtime/temp directory from an external API $response = craft()->assets->insertFileByLocalPath( $...
Dave Coggins's user avatar
4 votes
1 answer
2k views

How do I display a list of assets with the entries they are related to?

Given a list of assets, for each asset, how do I display a list of entries that relate to this asset? So, for instance, if asset A is selected as asset in entries 1 and 2, I want a list to be ...
Paul's user avatar
  • 6,348
4 votes
1 answer
393 views

Better way to find a specific asset?

I'm currently using a route to get a specific asset for a gallery section of my site. URL is similiar to http://craft.dev/place/place-name/gallery/1 (Where 1 is the number in the gallery.) I'm ...
Seán O'Grady's user avatar
3 votes
1 answer
221 views

Management of large number of downloadable PDFs

I'm rebuilding the main website for a small rural local council, and at this stage I am planning on using Craft. The main issue I have is around the management of several hundred PDF documents which ...
Jack McKenzie's user avatar
3 votes
1 answer
3k views

Object of class Craft\ElementCriteriaModel could not be converted to string

I have set up a Matrix field that contains a block type that contains among other things, an asset field. Trying to iterate through the contents of that matrix field works just fine for all other ...
Panos Spiliotis's user avatar
2 votes
2 answers
1k views

What is the proper way to set an asset's upload location using the slugs/ structure path of the entry it is selected from?

I'm working on a site with a structure containing products that are nested within "category"(not actually using craft's categories, just an entry type) pages. On each category or sub-category page I ...
Bonk's user avatar
  • 159
2 votes
1 answer
2k views

Is it possible to create a new asset from an image URL?

I've created several entries from a feed from the eBay API, but I would like to add images to the entry too! I've managed to get an array of URLs, which I would like to import into an assets field ...
joep's user avatar
  • 610
2 votes
1 answer
547 views

Is there a 'slug' for assets?

I'm trying to create a site with a gallery, and am investigating the possibility of getting Craft to treat an asset as an entry so I can display a detail page for an image without having to create an ...
Andy Harris's user avatar
2 votes
1 answer
110 views

How can I get a related Asset of a specific field?

I'm trying to grab an Asset which is a child of my Entry... $criteria = craft()->elements->getCriteria(ElementType::Asset); $criteria->childOf = $entryId; $photo = craft()->assets->...
Lindsey D's user avatar
  • 24.1k
2 votes
1 answer
396 views

File upload error in MS Azure after custom domain was pointed to Azure server

I am facing an issue with file uploads. I installed a new installation of Craft CMS on Microsoft Azure server. MS Azure assigns a default domain to your webapp like example.azurewebsites.net. So ...
dev barrierbreak's user avatar
2 votes
1 answer
327 views

Send an asset from a plugin controller

I have a controller which fetches an asset from an entry (this is the service method that provides the asset): public function findPoster($entryId) { $criteria = craft()->elements->...
Marty's user avatar
  • 181
2 votes
2 answers
498 views

Uploading an Asset from a custom CP-Tab in Craft 2.x

I have been looking through answers here at stackexchange but somehow can't figure out what i am missing. I simply want to upload an asset to a specific asset folder in my plugin. I do get an error: ...
HendrikEng's user avatar
  • 1,064
2 votes
1 answer
166 views

Accessing the attributes of an Asset field

Specifically looking at these attributes http://d.pr/i/1ilbr I can access Alt text by {{ entry.assetHandle.first().altText }} and similarly can do {{ entry.assetHandle.first().sourceUrl }} but Source ...
Steven Grant's user avatar
  • 1,855
1 vote
2 answers
823 views

How can I base64-encode an Image Transform?

I'm trying to use this plugin, but it requires an AssetFileModel as input. I can pass it the asset in question, no problem, but I'm wanting to pass it a transformed version of the asset. However, it ...
Sandwich's user avatar
  • 636
1 vote
2 answers
88 views

Error when outputting assets from a field within a Neo field

Anyone with Neo experience had issues with outputting an assets field with multiple images? I am not using a dynamic field, as I saw there are issues with that. Code {% for asset in block....
zizther's user avatar
  • 449
1 vote
1 answer
462 views

File input attachment format for Contact Form plugin

Is it possible to specify the file formats for an upload field with the Contact Form? Is it controlled by the extraAllowedFileExtensions setting?
sarah3585's user avatar
  • 899
1 vote
1 answer
303 views

Search for assets containing a custom field

How can I search for assets containing a custom field? The field on the asset is called lang. When I use this code no assets are found. {% set folderId = craft.app.request.getQueryParam('folderId') %} ...
Guido Neele's user avatar
1 vote
1 answer
948 views

List subfolders of a specific asset folder

Is it possible to list subfolders from a specific folder? Context: I'm printing out hundreds of icons which are maintained by moving a directory structure directly over to my public assets folder. ...
Ryan's user avatar
  • 11
1 vote
1 answer
144 views

How to retrieve the mode of an image transformation from its name?

I work on a portfolio with a large number of images with very high sizes and a lot of images transforms. The server on which this site is hosted reach these limits (images generations process are ...
Romain P.'s user avatar
  • 1,917
1 vote
1 answer
144 views

Next/Previous Asset or Image within Entry

I'm looking to create a way to navigate to the next/previous image in an entry's asset range and display only the current asset at one time(starting from first asset). {% extends '_layout.html' %} {%...
Rory Clifford's user avatar
1 vote
1 answer
835 views

Image asset URI returning null

I have entries that contain a single graphic asset. I'm trying to use the graphic as a background image in my template. However, I'm unable to output the URI for the asset. I'm using entry.graphic....
anguiac7's user avatar
  • 346
1 vote
1 answer
390 views

Can visitors 'force download' images stored on Amazon S3?

I have a large set of images, stored on Amazon S3. I would like my users to be able to download the original version of an image, rather then watching it in the browser. I know I can do this with PHP ...
Paul's user avatar
  • 6,348
1 vote
1 answer
582 views

Get all images from a section

I want to get all images from the section projekte which are bound to the asset field bild I then want to fiddle around with .limit() and maybe random filters. So I grabbed all images like described ...
KSPR's user avatar
  • 3,786
1 vote
0 answers
67 views

User Group specific asset paths

I've been doing some quite involved work on a site where we want to restrict user access to certain asset paths. Following the post at Assets Folder: Images don't show up I was directed to the ...
Cole Henley's user avatar
  • 1,741
0 votes
1 answer
507 views

CBdException: Column 'id' cannot be null

I receive the following error only when I clear the cache: When I try to rebuild the image index, all of my image paths go missing. I'm not sure what caused this error but I do need to fix it. I've ...
Leyla Badillo's user avatar