I think it's because it's not called "mediaService" in the Umbraco frontend - It appears to be in the backend C# though - I think what you're looking for is the mediaResource
So your snippet should look like this
angular.module("umbraco")
.controller("My.ContentApp", function ($scope, editorState, userService, contentResource, mediaResource)
That seems to list the services that are available in the UI, however I didn't find anything in that list that looked like it would provide what I needed.
I'll give your suggestion a spin though, thank you!
@bo Thank you for that suggestion.. it does work however that only returns a basic object and there aren't any really useful properties on it for my needs at least.
@Jan You're right! That does work indeed and I get the media object with everything I need. There's a property called mediaLink on the returned object (not url as I was expecting) that gives me a working link for the media.
Getting the media service in a Content App
Hi,
I'm trying to get the media service from inside a content app in v8.6.1
I was hoping that it could be injected like this:
But mediaService just raises the following error:
Does anyone know how I can get the media service injected?
Hi Keith
I think it's because it's not called "mediaService" in the Umbraco frontend - It appears to be in the backend C# though - I think what you're looking for is the mediaResource
So your snippet should look like this
I hope this helps!
/Jan
Thank you Jan, that's really helpful, I did find this...
https://our.umbraco.com/apidocs/v8/ui/#/api/umbraco.services
That seems to list the services that are available in the UI, however I didn't find anything in that list that looked like it would provide what I needed.
I'll give your suggestion a spin though, thank you!
So I gave your suggestion a spin and actually the mediaResource you mentioned is listed in that doc.. shame on me for missing it :)
However, I'm still being an idiot and not able to work out how to display a media image in a content app.
I have a media picker property, from which I can get the media path:
properties[3].value gives me:
I can't seem to get the id of the referenced media so I can't use:
and there doesn't seem to be a getByPath()
I'm trying to get the media item url so I can display it like this:
Hi Keith.
With Udi i think you need to use the
entityResource
likeHi Keith
It's a bit weird but you should be able to pass the udi to the
mediaResource.getById()
, which is not very obvious - But it should work.I hope this helps.
/Jan
@bo Thank you for that suggestion.. it does work however that only returns a basic object and there aren't any really useful properties on it for my needs at least.
@Jan You're right! That does work indeed and I get the media object with everything I need. There's a property called mediaLink on the returned object (not url as I was expecting) that gives me a working link for the media.
Thank you very much!
is working on a reply...