silverstripe / silverstripe-asset-admin

Silverstripe assets gallery for asset management
BSD 3-Clause "New" or "Revised" License
20 stars 79 forks source link

Image thumbnail not rendering in Tile view #973

Open cwchong opened 5 years ago

cwchong commented 5 years ago

Thumbnails not rendered in Tile view (default) in asset admin, if it is uploaded via code. Inside any page controller:

        $name = 'image.jpg';
        $filepath = 'source/to/' . $name;
        $output = 'assets/Covers/testing';
        if (!file_exists($output))
            mkdir($output);
        $folder = \SilverStripe\Assets\Folder::find_or_make('Covers/testing');

        $contents = file_get_contents($filepath);
        $img = \SilverStripe\Assets\Image::create();
        $img->setFromString($contents, 'Covers/testing/' . $name);
        $img->ParentID = $folder->ID;
        $img->write();
        \SilverStripe\AssetAdmin\Controller\AssetAdmin::create()->generateThumbnails($img);
        $img->publishRecursive();

In default Tile view, no thumbnail is rendered ss1 In Table view, thumbnail shown ss2 In details view, note that the image is already published ss3 Clicking publish again renders the thumbnail ss4

Additionally, the thumbnail file is created via code, so it is not a case of the thumbnail file actually missing. I believe there is some react/gql thing going on at js level that is not picking up the image if not done "through" uploadfield/cms

ScopeyNZ commented 5 years ago

I've taken the liberty of marking this UX issue as impact/high. I'd imagine in a large list a user relies on the thumbnails quite a lot to find their image.

christopherdarling commented 5 years ago

I have this problem on a project at the moment that makes use of the Imgix module (image processing CDN), so the resampled images are never stored on the local filesystem and only on the CDN. I found that I had to put the config below in order to get the images to work... thought I would share incase this helps as a similar issue

---
Name: app_imgix
After: assetadmingraphql-dependencies
---
SilverStripe\Core\Injector\Injector:
  SilverStripe\AssetAdmin\Model\ThumbnailGenerator.graphql:
    class: SilverStripe\AssetAdmin\Model\ThumbnailGenerator
    properties:
      Generates: true
brynwhyman commented 4 years ago

I think I might be seeing the same issue surfacing when a file is uploaded via the FileUploadField provided by the userforms module, using the Upload PHP API

brynwhyman commented 4 years ago

A new RFC has been raised that would support this: RFC Add API to do post file upload processing #399