Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
As I know, the root media ID is -1, anyway, next method works
-1
MediaService.CreateMedia("New media name", parentId: -1, "Folder");
But the next one returns null:
null
MediaService.GetById(-1); // null
Why? How to get a root of media section?
The item with id -1 dont exists. Umbraco is using -1 in the parentid to see if the item is root.
The item has a real id instead.
Hi, Niels
Hmm, pretty ugly API unfortunatly :( Seems it is some kind of lagacy, magic numbers is antipattern :(
By the way, I have found a litle better approach for it, it not the best, but better then nothing
Constants.System.Root // -1
Thanks
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to get a root media item?
As I know, the root media ID is
-1
, anyway, next method worksBut the next one returns
null
:Why? How to get a root of media section?
The item with id -1 dont exists. Umbraco is using -1 in the parentid to see if the item is root.
The item has a real id instead.
Hi, Niels
Hmm, pretty ugly API unfortunatly :( Seems it is some kind of lagacy, magic numbers is antipattern :(
By the way, I have found a litle better approach for it, it not the best, but better then nothing
Thanks
is working on a reply...