Forum

Thread tagged as: Question, Problem, Addons

No images in bucket in Assets Preview, until...

Hello,

I create buckets.php in my config file and create a bucket named "mosaics."

<?php
    return array(
        'mosaics' => array(
            'web_path'  => '/resources/mosaics',
            'file_path' => '/Applications/MAMP/htdocs/perch/resources/mosaics',
            'type' => 'image'
        )
    );  
?>

I then Add an Asset and choose the new "mosaics" bucket. The "mosaics" file is created in Resources with the image and created thumbnail (these are also in the database).

But only a placeholder image icon appears in Assets for the custom bucket item.

After mucking around, I find that if I remove the buckets.php file from config (or simply change the name to something like buckets_mosaics.php), the image appears in Assets.

Additionally, with no buckets.php in the config file (or with the name simply changed), I can now add Assets to the "mosaics" bucket and all appears as it should.

If I put the buckets.php file back in config, again only image placeholder icons appear.

So...I don't really have a problem (maybe), but I do have a question: what am I doing wrong, or perhaps more generally, what is happening with Assets Preview in this instance?

Diagnostics show Perch 2.7.4, PHP 5.6.2, MySQL 5.5.38. Image Manipulation: GD Extended diagnostics list- GD: yes ImageMagick: No

The default bucket works just fine.

Thank you.

John Rose

John Rose 6 points

  • 6 years ago

John. You keep referring to creating an buckets.php in your config file, do you really mean it's in your config file or do you mean in your config directory?

Also looking at your buckets.php your...

'web_path'=>'/resources/mosaics'

Would be placing resource in /resources/mosaics.

If you haven't created the folders they will not be created by perch. Perch only creates directory when bucket="bucketName" is used in a template tag. Buckets in buckets.php must be created manually.

CORRECTION: I recently learned the "manually created buckets" was incorrect. It was a configuration error on my installation. buckets.php does create the new bucket just the same as bucket="bucketName" does in template tags.

Thank you, yes, I referred to my config directory.

And thank you for your suggestion regarding web_path.

And regarding the rest, I appear to have completely confused myself. Apologies for that.

So are you up and running now?

Hello Robert and all,

So...I have been able to reproduce my results and to note more closely the sequence of events.

I create a buckets.php file "robtest" in my config directory:

<?php
    return array(
        'robtest' => array(
            'web_path'  => '/robtest',
            'file_path' => '/Applications/MAMP/htdocs/perch/resources/',
            'type' => 'image'
        )
    );  
?>  

At my Assets page, I refresh, and robtest is now available in the By Bucket dropdown.

I Add Asset, download my jpg image Swashbuckler 1, choose the robtest bucket, and at preview a placeholder icon shows, and when submitted the asset is added, again with the placeholder icon. In Assets list view, the image is listed with image dimensions and file size. At this point there is no folder "robtest" created in Resources.

I change my buckets.php file name to buckets_robtest.php (or remove it from the file).

Returning to Assets, I Add Asset "Swashbuckler 2" , choose the robtest bucket, and on submit there is a small screen hiccup. Checking my Resources file, a folder "robtest" has now been added.

I get back to adding the asset, and that is completed successfully, with the image, not the placeholder icon, in place.

I can now add any number of images of Robert the Swashbuckler and others to my Assets bucket "robtest".

If I change my buckets_robtest.php file back to buckets.php, the successfully loaded images now show the placeholder icons. Change it back to buckets_robtest.php, and the images re-appear.

On my page, the robtest Assets that showed as properly loaded are available for insertion.

Robert wrote earlier in this thread, "Perch only creates directory when bucket="bucketName" is used in a template tag." If by directory is meant the file in Resources with the bucket name, this would be an exception, with that folder being created without a template tag ever being used.

Now to figure out the correct way to do all this...

John,

Your code still doesn't look right...

YOUR POSTED CODE:

<?php
    return array(
        'robtest' => array(
            'web_path'  => '/robtest',
            'file_path' => '/Applications/MAMP/htdocs/perch/resources/',
            'type' => 'image'
        )
    );  
?>

CORRECTED: (and notes)

<?php
    return array(
        'robtest' => array(
            'web_path'  => '/perch/resources/robtest',
            'file_path' => '/Applications/MAMP/htdocs/perch/resources/robtest',
        )
    );  
/* I am not sure why you had 'type'=>'image' in your code, also you left off "robtest" in your file_path. */
?>

Hello Robert,

The 'type' => 'image' was something I came across in a Perch Forum post and gave it a try when I was getting Notices like those received in the instance below:

Pearch Forum link

I used your code- but without using bucket-bucketName in a tag template. The following shows up above the main header:

  • Notice: Undefined index: type in /Applications/MAMP/htdocs/perch/core/lib/PerchResourceBuckets.class.php on line 74

  • Notice: Undefined index: type in /Applications/MAMP/htdocs/perch/core/lib/PerchResourceBucket.class.php on line 15

  • Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/perch/core/lib/PerchResourceBuckets.class.php:74) in /Applications/MAMP/htdocs/perch/core/inc/top.php on line 13

  • Warning: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/perch/core/lib/PerchResourceBuckets.class.php:74) in /Applications/MAMP/htdocs/perch/core/inc/top.php on line 14

and at the File/Choose File area with Assets chosen:

  • Notice: Undefined index: type in /Applications/MAMP/htdocs/perch/core/lib/PerchResourceBuckets.class.php on line 74

  • Notice: Undefined index: type in /Applications/MAMP/htdocs/perch/core/lib/PerchResourceBucket.class.php on line 15

  • Your resources folder is not writable. Make this folder (/robtest) writable to upload images.

I forgot to mention:

Adding 'type' = 'image' to the corrected code from Robert eliminates the Notices and Warnings listed above, and at Add Asset Submit delivers:

Your resources folder is not writable. Make this folder (/robtest) writable to upload images.

Have you manually created the folder (directory) 'robtest' in "perch/resources"?

No, that is there now but I did not create it. It was created when I had had the buckets.php (robtest) in the config directory, which created the bucket option in the By Bucket on the Assets page, then Added one asset, which appeared only as an image placeholder icon, then changed the name to buckets_robtest.php (to essentially make it inactive).

Then, when I Added one Asset and clicked Submit, there was a little screen hiccup (hiccough), and it was created at that action. After that, I was able to Add Assets to the robtest bucket.

John, is this working now? Not sure if additional help is needed. :-)

Hello Robert and all,

Yes, everything works fine. I simply found it odd that buckets could be created via a buckets.php file in the config directory, but to view the actual images rather than icon placeholders in Assets I needed to remove or rename the buckets.php file. I am only on a dev site at this time.

Meanwhile, creating buckets via the documentation's Basic Buckets directions using the bucket attribute works fine.

I sometimes read directions from the end to the beginning, and so I first attempted the second method given in the documentation for Resource Buckets, namely Buckets List, where it was noted as being "for more advanced use."

I have no difficulty creating buckets using either method. But I have to think that I have another point to learn, since eliminating the buckets.php file to view the images seems not quite right.

I'll continue to monitor the Forum and see if this pops up again sometime.