Retrieve file by ID Silverstripe
up vote
1
down vote
favorite
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 | SilverStripeAssetsImage
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('SilverStripeAssetsImage', 2583);
In all cases is returning null
. Do you know what I am missing here?
php image file silverstripe silverstripe-4
add a comment |
up vote
1
down vote
favorite
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 | SilverStripeAssetsImage
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('SilverStripeAssetsImage', 2583);
In all cases is returning null
. Do you know what I am missing here?
php image file silverstripe silverstripe-4
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 at 13:49
1
Does the file exist? Is it published? Can you see it in the assets section of the admin area?
– wmk
Nov 14 at 20:53
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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 | SilverStripeAssetsImage
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('SilverStripeAssetsImage', 2583);
In all cases is returning null
. Do you know what I am missing here?
php image file silverstripe silverstripe-4
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 | SilverStripeAssetsImage
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('SilverStripeAssetsImage', 2583);
In all cases is returning null
. Do you know what I am missing here?
php image file silverstripe silverstripe-4
php image file silverstripe silverstripe-4
edited Nov 12 at 13:45
Barry
3,11571637
3,11571637
asked Nov 9 at 20:55
alysonsm
1,020711
1,020711
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 at 13:49
1
Does the file exist? Is it published? Can you see it in the assets section of the admin area?
– wmk
Nov 14 at 20:53
add a comment |
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 at 13:49
1
Does the file exist? Is it published? Can you see it in the assets section of the admin area?
– wmk
Nov 14 at 20:53
3
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 at 13:49
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 at 13:49
1
1
Does the file exist? Is it published? Can you see it in the assets section of the admin area?
– wmk
Nov 14 at 20:53
Does the file exist? Is it published? Can you see it in the assets section of the admin area?
– wmk
Nov 14 at 20:53
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53233157%2fretrieve-file-by-id-silverstripe%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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 at 13:49
1
Does the file exist? Is it published? Can you see it in the assets section of the admin area?
– wmk
Nov 14 at 20:53