Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [assets]

Files managed by Craft, stored in physical folders or (with Craft Pro) on Amazon S3, Rackspace Cloud, and Google Cloud.

0
votes
0answers
13 views

Uploading new assets gives “file already exists” error

My client's found that Craft is often giving her the following alert when uploading a new asset: A file with the name “image_name.jpg” already exists. I've tried renaming images to something ...
1
vote
1answer
13 views

Is there any way to replace the asset programatically?

In the CP, when we upload an image with a same name, craft will ask if we wanna keep both or replace. So in plugin, is there any way to do the replace?
1
vote
1answer
17 views

Craft strips out parenthesis in file names.

Is there any way to allow () in asset file names (ex. file(1).txt)? Craft strips it out when it saves. The only way I've found is to change it via ftp and update asset indexes. I've set ...
1
vote
0answers
23 views

How to setup assets in multi site where each site should have its own assets?

I have a setup with multi sites that are separate domains. site-a.com site-b.com I would also like to have assets separate for each site, like so: site-a.com/images/picture1.jpg site-b.com/...
1
vote
0answers
16 views

Plugin development: how can I check if user has the permissions to delete only his own assets?

I have a front-end form where logged users can upload and delete their personal files. These users have the strict minimum permissions required to interact with this form. They can only Create, ...
0
votes
0answers
29 views

How to upload an image to an entry?

In front-end, I have a file input field with the name headerImage. <input type="file" class="form-control" name="profileImage" accept="image/*"> At the back-end, I do something like this: $...
1
vote
2answers
46 views

background-image CSS property: how to do it right with Craft?

My current code is: #header { background-image: url('{{ sitePath }}/assets/toxicomental/header.png'); height: 150px; } Still, I don't get the image showing. What do I do wrong?
1
vote
1answer
14 views

Pull all assets from a specific volume subfolder id

Is there a way to pull all assets from a volume subfolder id? {% set entries = craft.entries.section('pages').type('genealogy').search('pageType:stake') %} {% for entry in entries.all() %} {% if ...
1
vote
2answers
25 views

Assets metadata: Matrix required?

I'd like to add very basic metadata to assets (Alttext, Caption..) I noticed in volumes you can add custom field types – but they're not appearing when editing the entry. I found it can be edited in ...
3
votes
1answer
25 views

Temporary Uploads - disable?

When browsing the assets, there is a "Temporary Uploads" folder. What is it for? Can I disable/hide it?
0
votes
1answer
45 views

Asset (image) public URL does not work

I wanted to include some uploaded assets (images) in an entry. The .url property in twig outputs the proper URL, in my case: http://localhost/craftcms/web/image/photo-2017-04-02-16-20-53-1.jpg ...
2
votes
1answer
23 views

How to get second asset?

I have an entry with an asset field that has up to 3 assets in it. If I want to load just the second asset in my template code, what's the syntax for this? (can't find any references/examples)
1
vote
1answer
19 views

How to create a border + border colour field on an image

My first question here... maybe one of a few! I've inherited a Craft project recently and don't have much experience with it. I want to allow admin to set a border (and border color) whenever they ...
0
votes
0answers
9 views

JPG assets won't upload with image driver GD

I'm really not sure what's going on here. The server has GD extension installed as the image driver. I cannot install imagemagik, it's outside of my control. Image assets like .png and .gif upload ...
2
votes
1answer
29 views

How to exclude child elements when looping through categories?

I've got a few categories set up with a few child categories for each. Each one has assets (PDFs) assigned to them, by going into the assets, double clicking, and setting the category field there. So ...
3
votes
1answer
24 views

Moving Craft assets from one S3 bucket to another

I have the task of moving a large amount of assets ~50gb from one amazon s3 bucket to another on another AWS account. I've figured out how to copy the files via S3 COPY, but I'm just wondering will it ...
0
votes
0answers
26 views

I can access an asset filename, but not its URL

At first I was trying to use the one(), but it always told me the Object of class Craft\ElementCriteriaModel could not be converted to string So searching the documents, I found first(), and that ...
1
vote
1answer
20 views

How to display a featured image in the list of entries

I created a field which uploads an image, and I want it to display it for each of my entries inside my for loop. What's the code I should use to do it?
1
vote
1answer
14 views

How can I prevent CMYK image colours being shifted when importing into Assets?

When importing CMYK images into Assets the colour of the image can be shifted dramatically. Often giving a washed out look. How can I prevent this and ensure the image colours are as accurate as ...
0
votes
0answers
19 views

No preview on active list

I'm having an issue once I want to pick one asset from all the uploaded assets list, due to I'm not able to view the preview thumbnail. Edit feature doesn't work either. Here you have an screenshot: ...
1
vote
0answers
30 views

Find All Levels of Subfolders under Assets

I'm working with images in subfolders, several levels deep, under the Assets parent folder. -Assets --Dept_A ---Jan15 --Dept_B ---Jan15 ---Jan16 I've come across this code (below), but it only ...
0
votes
0answers
39 views

Asset Subfolder Access (By P&T) - Subfolders of Subfolders?

I'm developing my first site and am using the Asset Subfolder Access (By P&T) to restrict uploads to Assets and subfolders. As I have subfolders of subfolders, I was wondering if it is possible to ...
1
vote
1answer
31 views

Getting image url from globals asset field

I can retrieve only the image title from the below code, I can't see why the image URL is showing as empty? its a global handle 'brand' and asset field 'logo': {% set image = brand.logo.one %} <a ...
1
vote
1answer
30 views

.limit(1) on asset field loop is effecting another loop on same page

I have an Asset field where the first image is used as a big 'feature' and then the rest are used as support further down the page. When I add .limit(1) to the for loop for the 'feature' image it ...
1
vote
1answer
23 views

Uploading assets to different locations based on environment

I'm currently working on a new Craft CMS website for my company. We're using Elastic Beanstalk for hosting, which means that saving assets to file on the server isn't really viable- they get ...
1
vote
1answer
50 views

Output assets within a matrix block using Imager and Craft 3

I'm having trouble trying to output assets from an Assets field that's within a Matrix block, using Imager. The code below is only outputting the first image that has been added, over and over for ...
0
votes
0answers
12 views

Localization for asset folders (craft 2)

I've built a "documents" section with subfolders. The page is offered in 3 languages, that's why I made 3 asset sources for each language. Then I wrote a tiny plugin for grabbing the directory ...
1
vote
1answer
37 views

getPath() does not return subfolder for S3 asset source

I'm reading through the Craft docs in relation to the AssetFileModel. Looking at the getPath() method, this reads in theory that it should return the full path to the asset relative to the root, ...
0
votes
0answers
19 views

Include the asset's volume in the eager loading. [Element API]

On Element API, I'm eager loading the header image like: $criteria = [ 'section' => $section, 'with' => ['categories', 'header_image'] ]; But, in the output, I cannot get the volume ...
0
votes
0answers
56 views

Managing assets on a blog-type multi-site

Im currently building a multi-site blog solution in craft 3. The idea is to have one site per blog and let all the blogs share the same fields with some variations in the templates based on their ...
2
votes
2answers
49 views

Craft 2 to Craft 3 upgrade: User Photos not migrated to User Accounts

I followed the instructions in the docs at https://docs.craftcms.com/v3/changes-in-craft-3.html#user-photos. I can browse the User Photos in the User Photos Asset Volume in the Control Panel. However,...
2
votes
1answer
67 views

“An unknown error occurred” in assets screen

I have a number of assets resources all set to upload to the same amazon s3 bucket. Two of my four assets resources show "An unknown error occurred" twice when I view them in /admin/assets. The ...
1
vote
1answer
17 views

Falling back to Parent Category if no asset exists

I'm trying to make it so that if an entry image does not exist, then fall back to the category image that the entry belongs to. Right now this isn't working and is receiving an error. {% set feature =...
1
vote
1answer
58 views

Deleting a user's profile photo via frontend in Craft3

I am having the hardest time allowing a user to delete their profile photo with Craft3. I have tried to follow this thread's answers : Allow user to change or delete their photo for their profile from ...
1
vote
1answer
52 views

How can I create a new asset source?

Now I have a "gallery image" field which allows users to upload multiple images, and some "single-upload image field" in matrix block. For "single-upload image field", I want to force users to ...
0
votes
0answers
32 views

Set object metadata on upload for remote assets (Google Cloud Storage)

Google Cloud Storage allows you to set metadata on objects at the time of upload. Is it possible to set this in Craft for files uploaded to a remote Asset volume? In my case I want to set Content-...
0
votes
0answers
13 views

Empty Asset URL Error [duplicate]

Currently trying to call an Asset URL but it's returning an error as some categories do not have an Asset uploaded yet. Impossible to invoke a method ("url") on a null variable. Code running it: ...
0
votes
0answers
29 views

Attach assets to entries by running queries directly on the database

Is the following possible? Upload a large number of images via FTP and then synch the Assets index. Each image filename contains an ID contained in an entry's custom field for matching against. Run ...
1
vote
1answer
488 views

Why do I get Access denied on s3 asset source images?

I have created an s3 bucket in aws and added the correct permissions and user group etc. I have added the below policy: { "Version": "2012-10-17", "Statement": [ { "Sid": "...
1
vote
2answers
65 views

How to use an asset as featured image in different entries

I have currently the problem, that I can't use the same asset in different entries as featured image. Craft Pro Version: 3.0.9 My setup is the following: Volumes: Local, Base URL: @web/uploads, ...
0
votes
0answers
14 views

How do you hide the contents of your S3 or CloudFront Directory?

So, I have PDFs stored in an S3 bucket delivered by a CloudFront distribution. How do I prevent somebody from erasing the filename in the URL and viewing all the contents of the CloudFront director -...
1
vote
1answer
22 views

How do you setup CloudFront in P&T S3 plugin & how do you know if it works?

I have the P&T Amazon S3 plugin. It's connected to my S3 bucket. It stores a few test .PDF files. It is working. I am able to access the files - and the URL is that of my S3 bucket - i.e., ...
2
votes
0answers
32 views

Required alt text field in assets

I'm not sure if this is a bug or I'm doing this wrong. I have an asset volume called "Blog Images" and there is a custom required field called Image alt text. If I add images in assets section I'm ...
0
votes
0answers
48 views

IMG with defined width/height in rich text field

I have a Rich Text field where the user (Craft 2.6) can upload/add images. However the <img> tag that gets generated just has the src on it and I need it to also define the IMG's true width/...
1
vote
1answer
25 views

Issue with validator getNameReplacementInFolder

I have issue with the following code: public function getNameReplacementInFolder(string $originalFilename, int $folderId): string { $folder = $this->getFolderById($folderId); if (!$folder)...
1
vote
1answer
112 views

block.image.one() shows more than one image

I'm sure I'm doing something wrong here, but I'm at a loss as to what. I'm using Craft 3. My travel entry has 7 fields, one of those being a matrix field. My matrix has two blocks, postText and ...
1
vote
1answer
21 views

Error using assets operations

I am having trouble getting images by name. craft.assets.first() function in assets gives the proper output of one image. But when I try craft.assets.filename('flag.jpg'), craft shows the following ...
1
vote
2answers
69 views

Saving asset programatically, eg via API

I'm working on a plugin in Craft 3 that is fetching a file reference (URL) via an API. I want to fetch the file and save it locally as an Asset. I've tried to do this via Craft::$app->getElements()...
1
vote
1answer
48 views

Uploaded images are saving to the server's temp folder and throwing 500 errors

I've got a wordpress site that is live and am building a craft site to replace it on a subdomain and am having a strange issue that I've never had with any other craft sites I've built. Sometimes when ...
2
votes
2answers
82 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: ...