-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Adds media url provider #5282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds media url provider #5282
Conversation
nice, haven't had time to fully look at this one but just wanted to ping @zpqrtbnk since he'll also have an interest in this one too. |
What does this implementation mean for regular every day use of Umbraco?
Just trying to get an idea of what would work and potentially what wouldn't when you have a CDN provider in place. Is there potential for getting media Urls without the CDN prefix. |
@sitereactor not sure if you've read all of the related issues? This is what this is fixing: #4942, this is the epic that contains it: https://github.com/umbraco/Umbraco.Private/issues/283, this is the spike with some research done #4943 |
Okay, I will try to think of another way to ask my question so you will understand. From your reply I gather its not clear 😅 |
How about this: Given all the tasks/subtasks mentioned in the #283 Epic are fully implemented. Will the use of getting a path/url to a media item be completely seemless to the user or is there anything that would require the developers to use different methods? Say I'm on version 8.0.x and all the tasks from the Epic is implemented in 8.x and I upgrade to this version and configure a media provider to add a CDN to the site. Will everything Just Work™️ ? |
Yes.. it will 'just work', that's the whole premise for these changes, we don't want the user to have to do new/different things. |
Great, thank you. |
For media I guess we could make |
What about from a package developers perspective? Anything special they'd need to be aware of? Something around how to handle media paths within content. |
throw new ArgumentOutOfRangeException(nameof(mode)); | ||
} | ||
|
||
return uri.Rewrite(UriUtility.ToAbsolute(uri.GetSafeAbsolutePath())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this does what we want. Calling ToAbsolute
on an already absolute url is... going to do weird things? Looking into it.
@rasmusjp I have pushed a commit that does some minor fixes, want to check I haven't done anything stupid? Now running tests. As for the behavior of Ideally, So in a view... Making sense? |
How do you get an absolute crop URL?
|
And all
|
BTW: adding support for culture variant media types will be required first: #4771. |
fixes #4942
Breaking changes
UrlProvider
constructors now takes anIEnumerable<IMediaUrlProvider>
UmbracoContextFactory
constructor now takes aMediaUrlProviderCollection
Things to test
media.Url
returns the url for theumbracoFile
property,media.UrlAbsolute()
returns the absolute url for theumbracoFile
property.media.GetCropUrl(200, 200)
returns the crop urlAdd a
Umbraco.UploadField
and aUmbraco.ImageCropper
property to a content item and test the following both as invariant and variantcontent.MediaUrl('propertyAlias')
returns the url for the media in thepropertyAlias
propertycontent.MediaUrlAbsolute('propertyAlias')
returns the absolute url for the media in thepropertyAlias
propertycontent.MediaUrl('propertyAlias', "culture")
returns the url for the media in thepropertyAlias
property in the specified culturecontent.MediaUrlAbsolute('propertyAlias', "culture")
returns the absolute url for the media in thepropertyAlias
property in the specified culturecontent.GetCropUrl(200, 200 propertyAlias: "propertyAlias")
returns the crop urlCrete a new implementation
IMediaUrlProvider
which always returns a full url and add it as the first one in theMediaUrlProviderCollection
e.g.and test that all the above url's now is prefixed with
https://my.cdn