Forum

Thread tagged as: Question, Problem

A couple of issues with assets/buckets

Hi,

I have been having a few issues with Assets/Buckets which I just want to see if anyone has a solution for or if its something relating to my code.

Issue 1: I create a template and define a bucket for a particular set of files or images. I then login to Perch and try and add an asset and the file/image looks like it uploads but then disappears rather than appearing in the bucket. This issue seems to be down to the naming convention of the bucket. Are there any rules for bucket naming? For example:

If I name a bucket as 'project-downloads' it wont work:

<perch:if exists="project-details">
  <p><a href="<perch:content id="project-details" type="file" label="Project Details Download" order="5" bucket="project-downloads" />" target="_blank">Download project details</a></p>
</perch:if>

Where as 'downloads' will work and upload assets as expected:

<perch:if exists="project-details">
  <p><a href="<perch:content id="project-details" type="file" label="Project Details Download" order="5" bucket="downloads" />" target="_blank">Download project details</a></p>
</perch:if>

Issue 2: I have more than one bucket in use on a template. If I upload an image to the bucket 'featured' all is good, but then I move on to add some images that are set to go into the 'portfolio' bucket in the template but they default in to the 'featured' one.

Template below:

<div class="project-detail">

    <div class="row">
        <div class="col-sm-6">
            <h1><perch:content id="project-title" type="text" label="Project Title" required="true" title="true" order="1" help="e.g. Dutch House" /></h1>
            <h2><perch:content id="project-location" type="text" label="Project Location" required="true" title="true" order="2" help="e.g. Shenfield, Essex" /></h2> 
            <h3><perch:content id="project-type" type="text" label="Project Type" required="true" order="3" help="e.g. Private Residence" /></h3>
        </div>
        <div class="col-sm-6">
            <perch:content id="project-detail" type="textarea" label="Project Detail" html="true" editor="ckeditor" required="true" order="4" />
            <perch:if exists="project-details">
                <p><a href="<perch:content id="project-details" type="file" label="Project Details Download" order="5" bucket="downloads" />" target="_blank">Download project details</a></p>
            </perch:if>
            <p><a href="/our-portfolio.php">Back to Our Portfolio</a></p>      
        </div>
    </div>

    <img src="<perch:content type="image" id="project-hero-image" label="Project Hero Image" width="1140" help="Images size should be 1140px wide. N.B. This image will populate the thumbnails throughout he site." bucket="portfolio" divider-before="Project Images" />" class="img-responsive" alt="<perch:content type="text" id="alt" label="Image Description" title="true" />" />

    <perch:blocks>

      <perch:block type="image" label="Single Image Block">
          <div class="row">
                <div class="col-sm-12">
                    <img src="<perch:content type="image" id="project-image" label="Project Image" width="1140" help="Images size should be 1140px wide" bucket="portfolio" />" class="img-responsive" alt="<perch:content type="text" id="alt" label="Image Description" />" />
                </div>
            </div>
      </perch:block>

      <perch:block type="images" label="Double Image Block">
          <div class="row">
                <div class="col-sm-6">
                    <img src="<perch:content type="image" id="project-image-double-1" label="Project Image" width="740" help="Images size should be 740px wide" bucket="portfolio" />" class="img-responsive" alt="<perch:content type="text" id="alt1" label="Image Description" />" />
                </div>
                <div class="col-sm-6">
                    <img src="<perch:content type="image" id="project-image-double-2" label="Project Image" width="740" help="Images size should be 740px wide" bucket="portfolio" />" class="img-responsive" alt="<perch:content type="text" id="alt2" label="Image Description" />" />
                </div>
            </div>
      </perch:block>

    </perch:blocks>

    <div class="to-top"><a href="#" class="top"><img src="/img/chevron-up.png" alt=""></a></div>

</div>

<div class="row">
    <div class="col-sm-12 text-center">
        <a href="/our-portfolio.php" class="page-link">Back to Our Portfolio</a>
    </div>
</div>

<perch:content id="slug" for="project-title" type="slug" suppress="true" />
<perch:categories id="type" label="Project category" set="type" help="e.g. Residential or Commercial" divider-before="Project Categories" />
<perch:categories id="featured" label="Featured Project" set="featured" help="Featured Project?" />
<perch:content type="image" id="project-hero-image" label="Project Hero Image" width="750" suppress="true" />
<perch:content type="image" id="featured-background-image" label="Background Image" width="1600" order="6" divider-before="Featured Background Image" help="Image size should be 1600 x 860px. This is for featured projects only." bucket="featured" suppress="true" />

Any help would be greatly appreciated...

Andy

Andy Knight

Andy Knight 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Bucket names have a maximum of 16 characters.

https://docs.grabaperch.com/docs/resources/buckets/

Ah OK, thanks Drew. Can we use hyphens in the bucket name e.g. team-images?

Any ideas on issue 2 above?

Hello Andy,

I'm not claiming any great knowledge about this, but id's do want underscores and not hyphens, so perhaps the same would be ideal for a bucket.

Have you tried uploading one image using your Project Hero Image option? Seems when I'm working that uploading an image is a way of creating the bucket, which will then be visible in Assets and available for use.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Hyphens shouldn't be a problem as long as your server's file system allows for that (most do).

Thanks John, looks like hyphens are ok too as per Drew's comment. Looks looks it was just the bucket name length being over 16 characters that was causing my issue.

In terms of point 2, the buckets are there already, so creation isn't a problem. Also, just to be clear, this issue is refering to uploading assets via a region not via the Assets app directly.

When I first go to the page in admin and choose 'Select or upload a file' on either "Project Details Download", "Featured Background Image" or "Project Image" all is fine. The correct bucket is selected in the 'Select an Asset' slide out panel.

If I then go on to add an asset that is set to use one of the other buckets, it defaults back to the previous bucket rather than changing to the one denoted by the template. This means that a client will probably upload to the wrong bucket by mistake.

FYI - If you press 'Save Changes' before moving to the next bucket the issue doesn't occur and each upload goes in to the correct bucket. Also, if you refresh the page in the browser between each upload the correct bucket is selected in the 'Select an Asset' slide out panel.

Looks like a cache issue perhaps?

Andy

Drew McLellan

Drew McLellan 2638 points
Perch Support

It sounds like that could be the case - we're taking a look into it.

OK, thanks Drew - let me know if you find anything.