2

I am currently using SilverStripe 4.1 and I am trying to retrieve an image from the database and it always returns null.

When I go to the database I see the file reference in the File table. Here is the File table content for the file I was trying to retrieve:

ID          | 2583
ClassName   | SilverStripe\Assets\Image
LastEdited  | 2018-11-08 21:05:48
Created     | 2018-11-08 21:05:48
Name        | logo-v5.png
Title       | logo-v5
ShowInSearch| 1
CanViewType | Inherit
CanEditType | Inherit
Version     | 1
ParentID    | 1753
OwnerID     | 10
FileHash    | 9e6faa29b752294d2e623bd83b17660df123af62
FileFilename| images/logo-v5.png
FileVariant | NULL

Here are the way I tried:

File::get()->byID(2583); 
Image::get()->byID(2583);  
File::get_by_id('SilverStripe\Assets\Image', 2583);

In all cases is returning null. Do you know what I am missing here?

Barry
  • 3,303
  • 7
  • 23
  • 42
alysonsm
  • 1,465
  • 1
  • 12
  • 16
  • 3
    bit of a guess, but is this something to do with publishing? i.e. do you need to publish it first as it is versioned? alternatively can you do `$file = File::get()->filter('Name', 'logo-v5.png')->first();`? – Barry Nov 12 '18 at 13:49
  • 2
    Does the file exist? Is it published? Can you see it in the assets section of the admin area? – wmk Nov 14 '18 at 20:53

0 Answers0